帮忙想想怎么做
输出:1 3 4 10 11 21 224 5 9 12 20 23 35
6 8 13 19 24 34 36
7 14 18 25 33 37 48
15 17 26 32 38 47 49
16 27 31 39 46 50 57
28 30 40 45 51 56 58
29 41 44 52 55 59 62
42 43 53 54 60 61 63
#include<stdio.h> #define Max 100 struct type{ int x; int mark; }type,a[Max][Max]; int main() { int i,j,k,n; printf("The number is :"); scanf("%d",&n); for(i=0;i<=n+1;i++) { a[i][0].mark=1; a[i][n+1].mark=1; a[0][i].mark=1; a[n+1][i].mark=1; } for(i=1;i<=n;i++) for(j=1;j<=n;j++) a[i][j].mark=0; i=1;j=1; for (k=1;k<=n*n;k++) { a[i][j].x=k; a[i][j].mark=1; if(i==1&&j<n) { if(a[i+1][j-1].mark!=0){j++;continue;} else{i++;j--;continue;} } else if(j==n) { if (a[i+1][j-1].mark!=0) {i++;continue;} else{i++;j--;continue;} } else if(j==1&&i<n) { if(a[i-1][j+1].mark!=0) {i++;continue;} else{ i--;j++;continue;} } else if (i==n) { if(a[i-1][j+1].mark!=0){j++;continue;} else{ i--;j++;continue;} } else { if(a[i-1][j+1].mark!=0){i++;j--;continue;} else{i--;j++;continue;} } } for(i=1;i<=n;i++) { printf("\n"); for(j=1;j<=n;j++) printf("%3d",a[i][j].x); } }