#include <iostream>
#include <iomanip>
using namespace std;
//格式化输出
int main()
{
int x = -10;
double d = 3.14;
cout << x << d << endl;
cout << '[' << setw(10) << x << ']' << endl;
cout << left;
cout << '[' << setw(10) << x << ']' << endl;
cout << internal;
cout << '[' << setw(10) << x << ']' << endl;
//以指定进制输出
x = 17;
cout << oct << x << endl;
cout << hex << x << endl;
cout << dec << x << endl;
cout << uppercase;
cout << showbase << hex << x << endl;
cout << showbase << oct << x << endl;
cout << showbase << dec << x << endl;
cout << showbase << x << endl;
//以科学计数法打印
cout << scientific << d << endl;
cout << fixed << d << endl;
//将缓冲区设置成一个字节
cout << unitbuf;
cout << "Hello";
cerr << "World";
cout << endl;
cout << setfill('#');
cout << setw(10) << x << endl;
//设置浮点数的打印精度
d = 3.1415;
cout << setprecision(4);
cout << d << endl;
}
/* 程序执行结果
-103.14
[ -10]
[-10 ]
[- 10]
21
11
17
0X11
021
17
17
3.140000E+00
3.140000
HelloWorld
########17
3.1415
*/