Noip Raise the group D1T1, has seen several times the question. But drag and drop, causing drag until today to AC off the topic.
It seems that there is really nothing to say about this problem, it is the details.
First the array must be initialized to 0, and then remember to continue.
#include <iostream>using namespacestd;inta[ A][ A],n;intMain () {Std::ios::sync_with_stdio (false); CIN>>N; inty= n/2+1, x=1; A[x][y]=1; for(intI=2; I <= n*n;++i) { if(x==1&& Y! =N) {x=N; ++y; A[x][y]=i; Continue; } if(Y==n && x!=1 ){ --x; Y=1; A[x][y]=i; Continue; } if(x==1&& y==N) { ++x; A[x][y]=i; Continue; } if(x!=1&& Y! =N) { if(a[x-1][y+1] ==0){ --x; ++y; A[x][y]=i; Continue; } Else{ ++x; A[x][y]=i; Continue; } } } for(inti =1; i<=n;i++) for(intj=1; j<=n;j++) {cout<<A[i][j]; if(J! = N) cout<<" "; Elsecout<<Endl; } return 0;}
"Simulation" Magical magic square