初学者求问格式控制符.
1.void main(){
const double e=2.718281828;
cout<<setprecision(10)<<e<<endl;
cout<<setiosflags(ios::fixed);
cout<<setprecision(9)<<e<<endl
<<setprecision(8)<<e<<endl;
cout<<setiosflags(ios::scientific)<<e<<endl;
}
2.void main()
{
const double e=2.718281828;
cout<<setprecision(10)<<e<<endl;
cout<<setiosflags(ios::scientific)<<e<<endl;
cout<<setiosflags(ios::fixed);
cout<<setprecision(9)<<e<<endl
<<setprecision(8)<<e<<endl;
}
输出:
1.
2.718281828
2.718281828
2.71828183
2.7182818
2.
2.718281828
2.7182818280e+00
2.71828183
2.7182818
1,2只是将cout<<setiosflags(ios::scientific)<<e<<endl;换了个位置,输出结果却不同了,求解。。。