Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
63518 李老师 方阵填数 C++ Wrong Answer 1 MS 280 KB 548 2024-01-11 15:28:53

Tests(0/3):


Code:

#include<iostream> using namespace std; int a[101][101]; int main(){ int n; cin>>n; int h=0; int l=n-1; int k=1; a[h][l]=k; while(k<n*n){ while((h+1<n)&&!a[h+1][l]){ k++; h++; a[h][l]=k; } while((l-1>=0)&&!a[h][l-1]){ k++; l--; a[h][l]=k; } while((h-1>=0)&&!a[h-1][l]){ k++; h--; a[h][l]=k; } while((l+1<n)&&!a[h][l+1]){ k++; l++; a[h][l]=k; } } for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ cout<<a[h][l]<<' '; } cout<<endl; } return 0; }


Run Info:

------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-----
100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100