62、<简单>有趣的图形-1
#include <iostream> #include <iomanip> // setw格式化输出 using namespace std; int main() { int n; cin >> n; // 外层循环:遍历每一行 for (int i = 0; i < n; i++) { // 内层循环:遍历当前行每一列 for (int j = 0; j < n; j++) { if (j < i) { // 左下,输出宽度为5的空格 cout << setw(5) << ""; } else { // 对角线及右上,输出数字 j-i+1,场宽5 cout << setw(5) << (j - i + 1); } } cout << endl; // 一行结束换行 } return 0; }