输出的对齐与填充字符

来源:互联网 发布:linux release 版本 编辑:程序博客网 时间:2024/05/16 23:21

头文件:<iomanip>


#include<iostream>  #include<iomanip>using namespace std;int main(){int a = 9999;int b = 999;int c = 99;cout << setw(6) << a << endl;cout.fill('#');//填充字符,如果想取消用#填充恢复以前的输出,可以设置成cout.fill(' ');cout << setw(6) << b << endl;cout << setw(6) << c << endl;/*默认是右对齐,若为左对齐,只需cout<<left<<setw(6)<<a<<endl;*/return 0;}


0 0
原创粉丝点击