c/c++ 输出格式控制

1、左补零

cout.fill('0');

cout.width(5);

cout << num;

2、添加任意字符c

#include<iomanip>

setfill(c)//设置填充字符为c

setprecision(n)//设置显示小数精度为n位

setw(n)//设置域宽为n个字符

setiosflags(ios::left)//左对齐

setiosflags(ios::right)//右对齐

---------------(ios::skipws)//忽略前导空白

---------------(ios::uppercase)//16进制数大写输出

---------------(ios::lowercase)//16进制数小写输出

---------------(ios::fixed)//固定的浮点显示

3、控制台下显示进度

printf("%lf \r", i/100);

你可能感兴趣的:(ios,c)