Chinaunix
标题:
不足10填充0使用cout
[打印本页]
作者:
CrossGrave
时间:
2016-01-04 00:24
标题:
不足10填充0使用cout
本帖最后由 CrossGrave 于 2016-01-04 00:30 编辑
自己已经学会,请版主关闭或者删除帖子 谢谢
会用printf来实现 具体不知道cout怎么实现,求助
作者:
bruceteen
时间:
2016-01-04 08:25
#include <cstdio>
#include <iostream>
#include <iomanip>
int main( void )
{
printf( "%010d\n", 123 );
std::cout << std::setfill('0') << std::setw(10) << 123 << '\n';
return 0;
}
复制代码
欢迎光临 Chinaunix (http://bbs.chinaunix.net/)
Powered by Discuz! X3.2