| Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|
| 130054 | huangyifeng2 | 方阵填数 | C++ | Wrong Answer | 1 MS | 276 KB | 1092 | 2025-09-07 14:46:24 |
#include<iostream> using namespace std; int a[101][101]; int n; int main() { cin >> n; int i = 0; int x = 1; int y = n; while (i <= n * n) { while (x >= 1 && x <= n && y >= 1 && y <= n && a[x][y] == 0) { i++; x++; a[x][y] = i; } x--; y--; while (x >= 1 && x <= n && y >= 1 && y <= n && a[x][y] == 0) { i++; y--; a[x][y] = i; } y++; x--; while (x >= 1 && x <= n && y >= 1 && y <= n && a[x][y] == 0) { i++; x--; a[x][y] = i; } x++; y++; while (x >= 1 && x <= n && y >= 1 && y <= n && a[x][y] == 0) { i++; y++; a[x][y] = i; } y--; x++; } for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { cout << a[i][j] << " "; } cout << endl; } return 0; }
------Input------
10
------Answer-----
28 29 30 31 32 33 34 35 36 1 27 58 59 60 61 62 63 64 37 2 26 57 80 81 82 83 84 65 38 3 25 56 79 94 95 96 85 66 39 4 24 55 78 93 100 97 86 67 40 5 23 54 77 92 99 98 87 68 41 6 22 53 76 91 90 89 88 69 42 7 21 52 75 74 73 72 71 70 43 8 20 51 50 49 48 47 46 45 44 9 19 18 17 16 15 14 13 12 11 10
------Your output-----
0 0 0 0 0 0 0 100 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0