提交时间:2024-01-31 20:44:12
运行 ID: 39298
#include<iostream> #include<algorithm> using namespace std; bool cmp(int a, int b) { return a > b; } int main() { int ji[15], ou[15], num, c1 = 0, c2 = 0; for (int i = 1; i <= 10; i++) { cin >> num; if(num % 2 == 0) { c2++; ou[c2] = num; }else{ c1++; ji[c1] = num; } } sort(ji + 1, ji + c1 + 1, cmp); sort(ou + 1, ou + c2 + 1); for (int i = 1; i <= c1; i++) cout << ji[i] <<" "; for (int i = 1; i <= c2; i++) cout << ou[i] <<" "; return 0; }