Advertisement
Guest User

27

a guest
Feb 24th, 2020
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.79 KB | None | 0 0
  1. //это 27
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <time.h>
  5.  
  6. int main(void)
  7. {  
  8.     srand(time(NULL));
  9.     system("chcp 1251>nul");
  10.     int amount, i, j;
  11.     int count = 0;
  12.     printf("Введите количество элементов в массиве: ");
  13.     scanf("%d", &amount);
  14.     int array[amount];
  15.  
  16.     for (i = 0; i < amount; i++)
  17.     {
  18.         array[i] = rand() % 50 + 1;
  19.         printf("array[%d] = %d\n", i, array[i]);
  20.     }
  21.     for (i = 0; i < amount; i++)
  22.     {   if ((array[i] < array[i+1]) && (i + 1 != amount))
  23.             printf("%d ", i);
  24.         else
  25.             if ((array[i] > array[i - 1]) && (i != 0))
  26.             {
  27.                 printf("%d\n", i);
  28.                 count++;
  29.             }
  30.     }
  31.     printf("Количество участков массива, на котором элементы монотонно возрастают: %d", count);
  32.     return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement