4条回答 默认 最新
Ouyang_Lianjun 2016-10-17 13:50关注首先我先指出你的错误:
你应该是想设置它是输出宽度,那么就要用:setw(),我写了一个例子:运行环境:vs2013
#include<iostream> #include<iomanip> using namespace std; int main() { /* setw(n)是设置输出的宽度,如果输出的宽度不够,会用空格补充 默认是右对齐 */ int a = 0; int b = 10; int c = 100; cout << setw(3) << a << endl; cout << setw(3) << b << endl; cout << setw(3) << c << endl; system("pause"); return 0; }本回答被题主选为最佳回答 , 对您是否有帮助呢?评论 打赏 举报解决 1无用 1
