iamvirus

用do while 的解法:

 1 #include<iostream>
 2 using namespace std;
 3 void main()
 4 {
 5     int i=1,j;
 6     do
 7     {    j=1;
 8         while(j<=i)
 9         {
10             cout<<i<<\'x\'<<j<<\'=\'<<i*j<<\' \';
11             j++;
12         }
13         cout<<endl;
14         i++;
15     }
16     while(i<=9);
17 }

用for循环实现:

 1 #include<iostream>
 2 using namespace std;
 3 void main()
 4 {
 5     int i,j;
 6     for(i=1;i<=9;i++)
 7     {
 8         for(j=1;j<=i;j++)
 9             cout<<i<<"x"<<j<<"="<<i*j<<\' \';
10             cout<<endl;
11     }
12 }

运行结果:

分类:

技术点:

相关文章:

  • 2021-10-06
  • 2021-11-15
  • 2022-03-09
  • 2021-12-09
  • 2021-12-29
猜你喜欢
  • 2022-01-01
  • 2021-12-23
  • 2021-06-08
  • 2021-05-04
  • 2021-08-01
相关资源
相似解决方案