1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| int a; cout << "input a:"; cin >> a;
cout << "dec:" << dec << a << endl;
cout << "hex:" << hex << a << endl;
cout << "oct:" << setbase(8) << a << endl;
string pt= "China";
cout << setw(10) << pt << endl;
cout << setfill('*') << setw(10) << pt << endl;
double pi=22.0/7.0;
cout << setiosflags(ios::scientific) << setprecision(8);
cout << "pi=" << pi << endl;
cout << "pi=" << setprecision(4) << pi << endl;
cout << "pi=" << setiosflags(ios::fixed) << pi << endl;
cout << "pi=" << fixed << pi << endl;
|