Files
homework/060201/九九乘法表.cpp
2026-02-02 11:24:09 -05:00

19 lines
503 B
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#include <iostream>
#include <iomanip> // 用于对齐输出
using namespace std;
int main() {
// 外层循环控制行数 (1-9)
for (int i = 1; i <= 9; ++i) {
// 内层循环控制每行显示的列数
for (int j = 1; j <= i; ++j) {
// 输出格式j * i = 结果
// 使用 std::setw(2) 确保结果占两位,输出更整齐
cout << j << " * " << i << " = " << setw(2) << i * j << " ";
}
// 每行结束后换行
cout << endl;
}
return 0;
}