Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #define N 5
- #define M 5
- int main(){
- int Special = 0;
- int o = 0;
- int sum = 0;
- int mas[N][M] = {{7, 1, 1, 1, 1},
- {7, 1, 1, 1, 1},
- {7, 1, 1, 1, 1},
- {7, 1, 1, 1, 1},
- {7, 1, 1, 1, 1}};
- for(int i = 0; i < N; i++) // Выводим mas в консоль
- {
- for(int j = 0; j < M; j++)
- {
- printf("%d, ", mas[i][j]);
- }
- printf("\n");
- }
- printf("\n");
- for(int i = 0; i < N; i++) // Ищем особые элементы
- {
- for(int j = 0; j < M; j++)
- {
- o = 0;
- while(o < j)
- {
- sum = sum + mas[i][o];
- o++;
- }
- if(o == j) o++;
- while(o > j && o < M)
- {
- sum = sum + mas[i][o];
- o++;
- }
- if(mas[i][j] > sum) Special++;
- sum = 0;
- }
- }
- printf("Osobih elementov: %d\n", Special);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement