fork download
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5. int N, i, j, array[100][100]={{0}};
  6.  
  7. while(scanf("%d", &N) != EOF){
  8. for(i=0; i<N; i++){
  9. for(j=0; j<N; j++){
  10. if((i>=N/3 && i<(N-(N/3))) && (j>=N/3 && j<(N-(N/3)))){
  11. array[i][j] = 1;
  12. }
  13. else if(i==j){
  14. array[i][j] = 2;
  15. }
  16. else if(j == (N-i-1)){
  17. array[i][j] = 3;
  18. }
  19. }
  20. }
  21.  
  22. array[N/2][N/2] = 4;
  23.  
  24. for(i=0; i<N; i++){
  25. for(j=0; j<N; j++){
  26. printf("%d", array[i][j]);
  27. }
  28. printf("\n");
  29. }
  30. printf("\n");
  31. }
  32.  
  33. return 0;
  34. }
  35.  
Success #stdin #stdout 0s 2160KB
stdin
11
stdout
20000000003
02000000030
00200000300
00011111000
00011111000
00011411000
00011111000
00011111000
00300000200
03000000020
30000000002