1 使用for 循环
#include <iostream>
using namespace std;
int main()
{int i, j;for (int i = 1; i <= 9; i++){for (int j = 1; j <= i; j++){cout << j << "*" << i << "=" << i * j << "\t";}cout << endl;}return 0;
};
2 使用while 循环
#include <iostream>
using namespace std;
int main()
{int i = 1;while (i < 10){int j = 1;while (j <= i){cout << j << "*" << i << "=" << i * j << "\t";j+=1;}cout << endl;i+=1;}return 0;
};
打印结果