Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <malloc.h>
- #include <stdio.h>
- #include <stdlib.h>
- int main()
- {
- int n, number_even = 0, pos_max = 0;
- scanf("%d", &n);
- int* mas;
- mas = (int*) malloc(n * sizeof(int));
- for (int i = 0; i < n; i++)
- {
- scanf("%d", &mas[i]);
- }
- for (int i = 0; i < n; i++)
- {
- if (mas[i] % 2 == 0)
- {
- number_even++;
- if (mas[i] > mas[pos_max])
- {
- pos_max = i;
- }
- }
- }
- n++;
- mas = realloc(mas, n * sizeof(int));
- mas[n-1] = number_even;
- int buff = mas[pos_max + 1];
- mas[pos_max+ 1] = mas[n-1];
- mas[n-1] = buff;
- for (int i = 0; i < n; i++)
- {
- printf("%d ",mas[i]);
- }
- free(mas);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement