0

如何格式化我的控制台输出,使其与 C++ 中的右侧对齐?

4

1 回答 1

5

使用操纵器标志std::right

例子

或者

这有效...

#include<iostream>
using std::cout;
using std::endl;


#include<iomanip>
using std::setw;

int main(){

 int x = 12345;

 cout << "Blah Blah Blah" << endl << setw(80) <<  x << endl;

 system("pause");

 return 0;
}
于 2010-09-29T18:33:27.457 回答