Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //это 27
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- int main(void)
- {
- srand(time(NULL));
- system("chcp 1251>nul");
- int amount, i, j;
- int count = 0;
- printf("Введите количество элементов в массиве: ");
- scanf("%d", &amount);
- int array[amount];
- for (i = 0; i < amount; i++)
- {
- array[i] = rand() % 50 + 1;
- printf("array[%d] = %d\n", i, array[i]);
- }
- for (i = 0; i < amount; i++)
- { if ((array[i] < array[i+1]) && (i + 1 != amount))
- printf("%d ", i);
- else
- if ((array[i] > array[i - 1]) && (i != 0))
- {
- printf("%d\n", i);
- count++;
- }
- }
- printf("Количество участков массива, на котором элементы монотонно возрастают: %d", count);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement