Advertisement
Lisaveta777

Матрица

Nov 5th, 2018
337
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.59 KB | None | 0 0
  1. //https://otvet.mail.ru/question/211343438
  2.  
  3. #include <stdio.h>
  4.  
  5. #define NINE 9
  6.  
  7. int main()
  8. {
  9.    int i,j,counter,gap,top=0;
  10.    int arr3[NINE][NINE]={0};
  11.    counter = gap = 1;
  12.  
  13.    for(j=0;j<NINE;j++)
  14.    {
  15.  
  16.        for(i=gap;i<NINE-gap;i++)
  17.        {
  18.            arr3[i][j]=counter++;
  19.        }
  20.  
  21.  
  22.  
  23.         if(top||gap==5)//gap decreases from now on
  24.         gap--,top++;
  25.         else if(gap<5)//gap increases here
  26.         gap++;
  27.  
  28.  
  29.    }
  30.    for(i=0;i<NINE;i++)
  31.    {
  32.        for(j=0;j<NINE;j++)
  33.         printf("%4d",arr3[i][j]);
  34.        printf("\n");
  35.    }
  36.  
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement