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
  1. #include <cstdio>
  2. #include <iostream>
  3. #include <iomanip>

  4. int main( void )
  5. {
  6.     printf( "%010d\n", 123 );
  7.     std::cout << std::setfill('0') << std::setw(10) << 123 << '\n';

  8.     return 0;
  9. }
复制代码





欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2