作者:张煜
×××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××
#include<iostream>
#include<iomanip>//在此处引入了iomanip头文件,其中包含有setw()函数的声明
using namespace std;
int main()
{
int Basic = 950, Allowance = 95, Total = 1045;
cout << setw(10) << "Basic" << setw(10) << Basic << endl
<< setw(10) << "Allowance" << setw(10) << Allowance << endl
<< setw(10) << "Total" << setw(10) << Total << endl;//setw是对于下一个<<插入进来的需要打印的数据来讲的
return 0;
}
//我们也可以编写自己的操作器:
//这是一个头文件的编写:
#include<iostream>
using namespace std;
ostream & symbol(ostream& output)//symbol是新的操纵器,它是 Rs 的表达式。需要显示字符串 Rs 时,可随时使用标识符symbol
{
return output << "\tRs";
}