Advertisement
semenrbt

3.2 static

Feb 18th, 2020
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.09 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #define N 5
  4. #define M 5
  5.  
  6. int main(){
  7.     int Special = 0;
  8.     int o = 0;
  9.     int sum = 0;
  10.     int mas[N][M] = {{7, 1, 1, 1, 1},
  11.                      {7, 1, 1, 1, 1},
  12.                      {7, 1, 1, 1, 1},
  13.                      {7, 1, 1, 1, 1},
  14.                      {7, 1, 1, 1, 1}};
  15.  
  16.     for(int i = 0; i < N; i++) // Выводим mas в консоль
  17.     {
  18.       for(int j = 0; j < M; j++)
  19.       {
  20.         printf("%d, ", mas[i][j]);
  21.       }
  22.       printf("\n");
  23.     }
  24.     printf("\n");
  25.  
  26.     for(int i = 0; i < N; i++) // Ищем особые элементы
  27.     {
  28.         for(int j = 0; j < M; j++)
  29.         {
  30.             o = 0;
  31.             while(o < j)
  32.             {
  33.                 sum = sum + mas[i][o];
  34.                 o++;
  35.             }
  36.             if(o == j) o++;
  37.             while(o > j && o < M)
  38.             {
  39.                 sum = sum + mas[i][o];
  40.                 o++;
  41.             }
  42.             if(mas[i][j] > sum) Special++;
  43.             sum = 0;
  44.         }
  45.     }
  46.     printf("Osobih elementov: %d\n", Special);
  47.  
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement