方法一:

cout.flags (ios::left);//设置对齐的标志位为左
 
2. cout<<left 
对齐选项:(leftright or internal).

manip setw ( int n );默认右对齐
setw(n) 设置固定宽度
Set field width
Sets the number of characters to be used as the field width for the next insertion operation.

smanip setfill ( char c );
// setfill example
#include <iostream>
#include <iomanip>
using namespace std;

int main () {
cout << setfill ('x') << setw (10);
cout << 77 << endl;
return 0;
}

This code uses setfill to set the fill character to 'x'. The output of this example is something similar to:
xxxxxxxx77
想要输出77********
cout<<left<<setw(10)<<setfill('x') 左对齐
 

相关文章:

  • 2021-04-22
  • 2021-05-28
  • 2022-12-23
  • 2022-12-23
  • 2021-08-21
  • 2022-12-23
  • 2022-02-05
  • 2022-02-03
猜你喜欢
  • 2022-12-23
  • 2021-12-04
  • 2022-02-07
  • 2022-01-15
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案