#include "cstdio" #include "algorithm" using namespace std; // comp 函数一次性按要求排序一个数组 bool comp3(int left, int right) { if (left % 2 == 1 && right % 2 == 0) { return true; } else if (left % 2 == 1 && right % 2 == 1 && left > right) { return true; } else if (left % 2 == 0 && right % 2 == 0 && left < right) { return true; } return false; } int main() { int n = 10; int arr[101]; int res[10]; for (int i = 0; i < n; ++i) { scanf("%d", &arr[i]); res[i] = arr[i]; } sort(arr, arr + 10, comp3); for (int i = 0; i < 10; ++i) { printf("%d ", arr[i]); } return 0; }