setw、setfill、setprecision的使用问题,请高手解答,谢谢!
#include <iostream>#include<iomanip>
using namespace std;
int main()
{
int number=101,y;
double z=123.456789,g=123.123123123;
cout<<"decimal:"<<dec<<number<<endl;
cout<<"hexadecimal:"<<hex<<number<<endl;
cout<<"octal:"<<oct<<number<<endl;
number=10;
cout<<setfill('*')<<setw(2)<<number<<endl;
cout<<setw(3)<<number<<endl;
cout<<setw(4)<<number<<endl;
cout<<setfill('+');
cout<<setw(4)<<number<<endl;
y=123456;
cout<<setprecision(3)<<setw(3)<<y<<endl;
cout<<setprecision(3)<<setw(3)<<z<<endl;
cout<<setprecision(6)<<setw(3)<<z<<endl;
cout<<setprecision(6)<<setw(3)<<g<<endl;
cout<<setprecision(2)<<setw(3)<<g<<endl;
cin.get();
return 1;
}
以上代码在DEV-C++ 5编译运行的结果(附图)让人费解,请高手具体解答一下在number赋值为10以后的显示结果,谢谢。
result.JPG
(6.52 KB)