(C++)一些输出端的好玩小技巧

setw和setfill

​ 还在为输出前导零感到头疼?不想手写转换成字符串输出?想补齐其他东西?setwsetfill是你的好帮手!

​ 所需前置头文件:iomanip(就是In and Out Manipulation,挺好记的)

用例(补齐前导零):

int width = [总长度];
cout << setw(width) << setfill('0');

​ [待补充]

posted @ 2024-03-26 21:24  ComputerEngine  阅读(15)  评论(0编辑  收藏  举报