#include<iostream>
using namespace std;
int main()
{
int a[10];
while (cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4] >> a[5] >> a[6] >> a[7] >> a[8] >> a[9]) {
int count = 0;
for (int i = 0; i < 10; i++) {
if (a[i] % 2 != 0) {
for (int j = count; j < i; j++) {
if (a[j] % 2 == 0) {
int temp = a[i];
a[i] = a[j];
a[j] = temp;
}
}
count++;
}
}//把奇数都放在前面
for (int i = 0; i < count-1; i++) {
for (int j = 0; j < count - 1 - i; j++) {
if (a[j] < a[j + 1]) {
int t = a[j];
a[j] = a[j + 1];
a[j + 1] = t;
}
}
}
for (int i = count; i <9; i++) {
for (int j = count; j < 9 - i+count; j++) {
if (a[j] > a[j + 1]) {
int t = a[j];
a[j] = a[j + 1];
a[j + 1] = t;
}
}
}
for (int i = 0; i < 10; i++) {
cout << a[i] << " ";
}
cout << endl;
}
}
整数奇偶排序输入10个整数,彼此以空格分隔 重新排序以后输出(也按空格分隔),要求: 1.先输出其中的奇数,并按从大到小排列; 2.然后输出其中的偶数,并按从小到大排列。
2021/11/27 17:09:25