C++打印乘法表

#include <iostream>
#include <Windows.h>
#include <iomanip>

using namespace std;
int main(void) { int width; for (int i = 1; i <= 9; i++) { for (int j = 1; j <= i; j++) { width = (j == 1) ? 1 : 2; cout << j << "x" << i << "=" << setw(width) << left << i * j << " "; } cout << endl; } system("pause"); return 0; }

猜你喜欢

转载自www.cnblogs.com/tanghaiyong/p/11426611.html