Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <conio.h>
- #include <stdio.h>
- #include <stdlib.h>
- int main()
- {
- int size;
- printf("Enter size array\n");
- scanf_s("%d", &size);
- int *a = (int*)calloc(size, sizeof(int));
- printf("Enter elements array\n");
- for (int i = 0; i < size; i++)
- scanf_s("%d", a + i);
- for (int i = 1; i < size; i += 2)
- if (a[i]> 0) {
- int minIndex = i;
- for (int j = i + 2; j < size; j += 2)
- if (a[j] < a[minIndex])
- minIndex = j;
- int tm = a[i];
- a[i] = a[minIndex];
- a[minIndex] = tm;
- }
- printf("Out array\n");
- for (int i = 0; i < size; i++)
- printf("%d ", a[i]);
- free(a);
- _getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment