Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.17 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3.  
  4. int main()
  5. {
  6. int n,i,j,way;
  7. scanf("%d",&n);
  8. int arr[n][n];
  9. scanf("%d",&way);
  10. for(i=0;i<n;i++)
  11. {
  12. for(j=0;j<n;j++)
  13. {
  14. scanf("%d",&arr[i][j]);
  15. }
  16. }
  17. int x=n/2;
  18.  
  19. int y=x;
  20. printf("%d",arr[x][y]);
  21.  
  22. if(way == 0)
  23. {
  24. for(i=1;i<n;i++)
  25. {
  26. if(i%2 == 1)
  27. {
  28. for(j=1;j<=i;j++)
  29. {
  30. y--;
  31. printf("%d",arr[x][y]);
  32. }
  33. for(j=1;j<=i;j++)
  34. {
  35. x--;
  36. printf("%d",arr[x][y]);
  37. }
  38. }
  39. else
  40. {
  41. for(j=1;j<=i;j++)
  42. {
  43. y++;
  44. printf("%d",arr[x][y]);
  45. }
  46. for(j=1;j<=i;j++)
  47. {
  48. x++;
  49. printf("%d",arr[x][y]);
  50. }
  51. }
  52. }
  53. for(i=1;i<n;i++)
  54. {
  55. y--;
  56. printf("%d",arr[x][y]);
  57. }
  58.  
  59. }
  60. if(way == 1)
  61. {
  62. for(i=1;i<n;i++)
  63. {
  64. if(i%2 == 1)
  65. {
  66. for(j=1;j<=i;j++)
  67. {
  68. x--;
  69. printf("%d",arr[x][y]);
  70. }
  71. for(j=1;j<=i;j++)
  72. {
  73. y++;
  74. printf("%d",arr[x][y]);
  75. }
  76. }
  77. else
  78. {
  79. for(j=1;j<=i;j++)
  80. {
  81. x++;
  82. printf("%d",arr[x][y]);
  83. }
  84. for(j=1;j<=i;j++)
  85. {
  86. y--;
  87. printf("%d",arr[x][y]);
  88. }
  89. }
  90. }
  91. for(i=1;i<n;i++)
  92. {
  93. x--;
  94. printf("%d",arr[x][y]);
  95. }
  96.  
  97. }
  98. if(way == 2)
  99. {
  100. for(i=1;i<n;i++)
  101. {
  102. if(i%2 == 1)
  103. {
  104. for(j=1;j<=i;j++)
  105. {
  106. y++;
  107. printf("%d",arr[x][y]);
  108. }
  109. for(j=1;j<=i;j++)
  110. {
  111. x++;
  112. printf("%d",arr[x][y]);
  113. }
  114. }
  115. else
  116. {
  117. for(j=1;j<=i;j++)
  118. {
  119. y--;
  120. printf("%d",arr[x][y]);
  121. }
  122. for(j=1;j<=i;j++)
  123. {
  124. x--;
  125. printf("%d",arr[x][y]);
  126. }
  127. }
  128. }
  129. for(i=1;i<n;i++)
  130. {
  131. y++;
  132. printf("%d",arr[x][y]);
  133. }
  134. }
  135. if(way == 3)
  136. {
  137. for(i=1;i<n;i++)
  138. {
  139. if(i%2 == 1)
  140. {
  141. for(j=1;j<=i;j++)
  142. {
  143. x++;
  144. printf("%d",arr[x][y]);
  145. }
  146. for(j=1;j<=i;j++)
  147. {
  148. y--;
  149. printf("%d",arr[x][y]);
  150. }
  151. }
  152. else
  153. {
  154. for(j=1;j<=i;j++)
  155. {
  156. x--;
  157. printf("%d",arr[x][y]);
  158. }
  159. for(j=1;j<=i;j++)
  160. {
  161. y++;
  162. printf("%d",arr[x][y]);
  163. }
  164. }
  165. }
  166. for(i=1;i<n;i++)
  167. {
  168. x++;
  169. printf("%d",arr[x][y]);
  170. }
  171. }
  172.  
  173. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement