Align Integer using cout in C++
I need C++ to use cout to print:
Header
1
开发者_运维问答 2
3
4
5
10
11
12
instead of
Header
1
2
3
4
5
10
11
12
How should I format this using cout?
use the IO manipulator setw
#include <iostream>
#include <iomanip>
int main()
{
std::cout << "Header\n";
for(int i=1; i<13; ++i)
std::cout << std::setw(6) << i << '\n';
}
精彩评论