Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
111886 | 陈铎文 | 螺旋矩阵 | C++ | Wrong Answer | 1 MS | 264 KB | 369 | 2025-03-08 09:24:34 |
#include<bits/stdc++.h> using namespace std; int n; int main(){ int a[11][11]={},t=1; cin>>n; for(int i=0;i<n;i++){ if(i%2==0){ for(int j=0;j<n;j++){ a[j][i]=t++; } } else{ for(int j=n-1;j>=0;j--){ a[j][i]=t++; } } } for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ printf("%3d",a[i][j]); } cout<<endl; } }
------Input------
5
------Answer-----
1 2 3 4 5 16 17 18 19 6 15 24 25 20 7 14 23 22 21 8 13 12 11 10 9
------Your output-----
1 10 11 20 21 2 9 12 19 22 3 8 13 18 23 4 7 14 17 24 5 6 15 16 25