setw()是用来控制后面的输出长度的。

使用需调用:

include<iomanip>

eg:

cout<<setw(5)<<"s"<<endl;

结果为:    s;//四个空格加一个s共占5个字符

 

setw()默认填充为" "(空格),可以通过setfill()命令更改填充字符。

 

eg:

cout<<setfill("*")<<setw(5)<<"s"<<endl;

结果为:****s;

 

参考:http://www.cplusplus.com/reference/iomanip/setw/

https://zhidao.baidu.com/question/358913227.html

相关文章:

  • 2021-12-23
  • 2022-02-16
  • 2022-02-20
  • 2021-06-25
  • 2021-05-25
  • 2021-10-12
  • 2021-11-21
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2023-03-09
  • 2021-08-01
  • 2023-03-20
  • 2021-06-28
相关资源
相似解决方案