Programming training perception 1

The output is not aligned when printing the multiplication table

Control the width of the output through the setw() function
Insert picture description here

Go to the blog settings page, choose a code piece highlighting style you like, the same highlighting is shown below 代码片.

cout << setw(2) << std::left << i*j << " "; 

Set the output width to 2, left-justified

Insert picture description here

Still feel uncomfortable, the first column also shows the width of 2, the result is only one

Insert picture description here
Insert picture description here
The above is from the programming training articles learned by C++ teacher Rock

Guess you like

Origin blog.csdn.net/jjswift/article/details/104193349