#define _CRT_SECURE_NO_WARNINGS 1 #include<stdio.h> #include<stdlib.h> #include<assert.h> void even_old_number(int *arr, int len) { assert(arr); int i = 0; int j = 0; int tmp = 0; for (i = 0; i < len; i++) { while ((arr[i] % 2 == 0) && (i < len)) { i++; } while ((arr[j] % 2 == 1) && (j < len)) { j++; } if (i == len || j == len) return; if (i > j) { tmp = arr[i]; arr[i] = arr[j]; arr[j] = tmp; tmp = i; i = j; j = tmp; } } } int main() { int arr[] = { 1, 2, 3, 4, 5 }; int len = sizeof(arr) / sizeof(arr[0]); even_old_number(arr, len); int i = 0; for (i = 0; i < len; i++) { printf("%d ", arr[i]); } system("pause"); return 0; }