Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //https://otvet.mail.ru/question/211343438
- #include <stdio.h>
- #define NINE 9
- int main()
- {
- int i,j,counter,gap,top=0;
- int arr3[NINE][NINE]={0};
- counter = gap = 1;
- for(j=0;j<NINE;j++)
- {
- for(i=gap;i<NINE-gap;i++)
- {
- arr3[i][j]=counter++;
- }
- if(top||gap==5)//gap decreases from now on
- gap--,top++;
- else if(gap<5)//gap increases here
- gap++;
- }
- for(i=0;i<NINE;i++)
- {
- for(j=0;j<NINE;j++)
- printf("%4d",arr3[i][j]);
- printf("\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement