1001.cpp 407 B

12345678910111213141516171819
  1. #include <iostream>
  2. #include <algorithm>
  3. using namespace std;
  4. bool cmp(int a, int b) {
  5. if (a%2==1 && b%2==0) return true;
  6. if (a%2==1 && b%2==1) return a > b;
  7. if (a%2==0 && b%2==0) return a < b;
  8. return false;
  9. }
  10. int main() {
  11. int arr[10];
  12. for (int i = 0; i < 10; ++i) cin >> arr[i];
  13. sort(arr, arr+10, cmp);
  14. for (int i = 0; i < 10; ++i) cout << arr[i] << " ";
  15. return 0;
  16. }