Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pastebin
- #include <stdio.h>
- #include <math.h>
- #define SIZE 10
- //https://otvet.mail.ru/question/211269192
- //for an array - does sum for part of it, down from 2 diagonales
- void pop_arr(int *,int);
- void pr_arr(int *,int);
- int main()
- {
- int i,j,arr[SIZE][SIZE],total,step = 0;
- total = 0;
- for(i=0;i<SIZE;i++)
- {
- for(j=0;j<SIZE;j++)
- {
- arr[i][j]= SIZE*i+j;
- printf("%d\t",arr[i][j]);
- }
- printf("\n");
- }
- for(i = SIZE/2;i<SIZE;i++)
- {
- for(j = 0;j<SIZE;j++)
- {
- if(j>=SIZE/2-step&&j<=SIZE/2+step)
- total+=arr[i][j];
- }
- printf("\n");
- step++;
- }
- printf("total is %d now\n",total);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement