c++中的setw(n)是设置域宽。
就是你的输出要占多少个字符
类似于普通c中的printf(“%4d”,a);中的%nd
比如:
cout<
12345123
cout<
12345(两个空格)123
设置域宽.相当于C语言里的printf("%2d");
看下面程序的输出就清楚了
#include
#include
using namespace std;
void main()
{
int a=1;
cout<}
c++中的setw(n)是设置域宽。
就是你的输出要占多少个字符
类似于普通c中的printf(“%4d”,a);中的%nd
比如:
cout<
12345123
cout<
12345(两个空格)123
设置域宽
就是置2个空格~