题目链接:http://ybt.ssoier.cn:8088/problem_show.php?pid=1181
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 20;
int odd[N], o; // 奇数
int even[N], e; // 偶数
bool cmp(int x, int y)
{
return x > y;
}
int main()
{
for (int i = 0; i < 10; i++)
{
int x;
cin >> x;
if (x & 1)
{
odd[o++] = x;
}
else
{
even[e++] = x;
}
}
sort(odd, odd + o, cmp);
for (int i = 0; i < o; i++)
{
cout << odd[i] << " ";
}
sort(even, even + e);
for (int i = 0; i < e; i++)
{
cout << even[i] << " ";
}
return 0;
}