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; }

 

posted @ 2019-08-28 21:23  你爱过大海我爱过你  阅读(731)  评论(0编辑  收藏  举报