Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
2991 | 邓小龙 | 螺旋矩阵 | C++ | Wrong Answer | 0 MS | 264 KB | 639 | 2024-03-16 12:41:09 |
# include<iostream> # include<iomanip> using namespace std; int main(){ int x=0,n,a[20][20]; cin>>n; for(int j=0;j<n-1;j++){ x++; a[j][0]=x; } for(int i=0;i<n-1;i++){ x++; a[n-1][i]=x; } for(int j=n-1;j>0;j--){ x++; a[j][n-1]=x; } for(int i=n-1;i>0;i--){ x++; a[0][i]=x; } a[n/2][n/2]=x+1; for(int j=0;j<n;j++){ for(int i=0;i<n;i++){ cout<<setw(4)<<a[i][j]; } cout<<endl; } return 0; }
------Input------
12
------Answer-----
1 2 3 4 5 6 7 8 9 10 11 12 44 45 46 47 48 49 50 51 52 53 54 13 43 80 81 82 83 84 85 86 87 88 55 14 42 79 108 109 110 111 112 113 114 89 56 15 41 78 107 128 129 130 131 132 115 90 57 16 40 77 106 127 140 141 142 133 116 91 58 17 39 76 105 126 139 144 143 134 117 92 59 18 38 75 104 125 138 137 136 135 118 93 60 19 37 74 103 124 123 122 121 120 119 94 61 20 36 73 102 101 100 99 98 97 96 95 62 21 35 72
------Your output-----
1 2 3 4 5 6 7 8 9 10 11 12 44 0 0 0 0 0 0 0 0 0 0 13 43 0 0 0 0 0 0 0 0 0 0 14 42 0 0 0 0 0 0 0 0 0 0 15 41 0 0 0 0 0 0 0 0 0 0 16 40 0 0 0 0 0 0 0 0 0 0 17 39 0 0 0 0 0 45 0 0 0 0 18 38 0 0 0 0 0 0 0 0 0 0 19 37 0 0 0 0 0 0 0 0 0 0 20 36 0 0 0 0 0 0 0 0 0 0 21 35 0