Bob103

Для лизы 3

Mar 11th, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. #include <conio.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. int main()
  5. {
  6. int size;
  7. printf("Enter size array\n");
  8. scanf_s("%d", &size);
  9. int *a = (int*)calloc(size, sizeof(int));
  10. printf("Enter elements array\n");
  11. for (int i = 0; i < size; i++)
  12. scanf_s("%d", a + i);
  13. for (int i = 1; i < size; i += 2)
  14. if (a[i]> 0) {
  15. int minIndex = i;
  16. for (int j = i + 2; j < size; j += 2)
  17. if (a[j] < a[minIndex])
  18. minIndex = j;
  19. int tm = a[i];
  20. a[i] = a[minIndex];
  21. a[minIndex] = tm;
  22. }
  23. printf("Out array\n");
  24. for (int i = 0; i < size; i++)
  25. printf("%d ", a[i]);
  26. free(a);
  27. _getch();
  28. return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment