乘法表

问题:

输出如下的一个乘法表:

代码:

 1 #include<iostream>
 2 #include<iomanip>
 3 
 4 using std::cout;
 5 using std::endl;
 6 using std::cin;
 7 using std::setw;
 8 
 9 int main(){
10     cout << endl << "   " << " | ";
11     for (int i = 1; i <= 12;i++)
12     {
13         cout << setw(4) << setiosflags(std::ios::left) << i;
14     }
15     cout << endl;
16     for (int i = 1; i <= 14; i++)
17     {
18         cout <<"____";
19     }
20         for (int i = 1; i <= 12; i++)
21     {
22         cout << endl << setw(3)  <<setiosflags(std::ios::left) << i;
23         cout << " | ";
24         for (int j = 1; j <= 12;j++)
25         {
26             int result = i*j;
27             cout << setw(4) << result ;
28         }    
29     }
30     cout << endl;
31     return 0;
32 }

分析:

我还是搞不清楚为什么一个循环内setiosflags的left和right不能共存。

各位大神多多指教
原文地址:https://www.cnblogs.com/dushenda/p/9651328.html