iomanip
设置输出格式
include<iomanip>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| cout<<setprecision(9)<<a; cout<<setiosflags(ios::fixed)<<a; cout<<setiosflags(ios::fixed)<<setprecision(9)<<a;
cout<<setiosflags(ios::showbase);
cout<<hex<<a; cout<<setiosflags(ios::apperence)<<a; cout<<setw(10)<<b<<","<<b; cout<<setfill("*")<<setw(10)<<b<<","<<b; cout<<setiosflags(ios::positive)<<b;
cout << "oct: " << showbase << setbase(8) << a << " " << oct << a << endl; cout << "dec: " << showbase << setbase(10) << a << " " << dec << a << endl; cout << "hex: " << showbase << setbase(16) << a << " " << hex << a << endl;
cout << fixed <<setprecision(12) << pi << endl; cout<<setiosflags(ios::left); cout<<setiosflags(ios::right);
|
资料
https://www.cnblogs.com/lsgxeva/p/7696410.html