#include <vector>
#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;
bool cmp(const int a, const int b);
int main()
{
#ifndef ONLINE_JUDGE
ifstream cin("d:\\OJ\\uva_in.txt");
#endif
vector<int> v(10);
while (cin >> v[0] >> v[1] >> v[2] >> v[3] >> v[4] >> v[5] >> v[6] >> v[7] >> v[8] >> v[9]) {
sort(v.begin(), v.end(), cmp);
bool first = true;
for (int i = 0; i < 10; i++) {
if (first) first = false;
else cout << " ";
cout << v[i];
}
cout << endl;
}
return 0;
}
bool cmp(const int a, const int b)
{
if ((a & 1) && !(b & 1)) return true;
else if (!(a & 1) && (b & 1)) return false;
else if ((a & 1) && (b & 1)) return a > b;
else return a < b;
}
题目1117:整数奇偶排序
最新推荐文章于 2022-01-27 16:25:47 发布