C ++ print multiplication table

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

 

Guess you like

Origin www.cnblogs.com/tanghaiyong/p/11426611.html