Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
109069 | 汤奕硕 | 打印数字图形 | C++ | Wrong Answer | 1 MS | 268 KB | 566 | 2025-01-25 16:47:35 |
#include <iostream> using namespace std; void printPattern(int n) { for (int i = 1; i <= n; i++) { // 外层循环控制行数 // 打印递增部分 for (int j = 1; j <= i; j++) { cout << j << " "; } // 打印递减部分(不包括中间的数字) for (int j = i - 1; j >= 1; j--) { cout << j << " "; } // 换行 cout << endl; } } int main() { int n; while (cin >> n) { // 多组输入 printPattern(n); } return 0; }
------Input------
8
------Answer-----
1 121 12321 1234321 123454321 12345654321 1234567654321 123456787654321 1234567654321 12345654321 123454321 1234321 12321 121 1
------Your output-----
1 1 2 1 1 2 3 2 1 1 2 3 4 3 2 1 1 2 3 4 5 4 3 2 1 1 2 3 4 5 6 5 4 3 2 1 1 2 3 4 5 6 7 6 5 4 3 2 1 1 2 3 4 5 6 7 8 7 6 5 4 3 2 1