文章
79
粉丝
221
获赞
46
访问
198.4k
#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]) {
bool sel[10] = { false };
for (int i = 0, flag=0, max=-1; i < 10; i++, max = -1,flag = 0) {
for (int j = 0; j < 10; j++)
if (a[j] % 2 != 0 && sel[j] == false && (max == -1 || a[j] > a[max])) {
flag = 1;
max = j;
}
if (flag == 0)
break;
else {
sel[max] = true;
cout << a[max] << " ";
}
}
for (int i = 0, flag=0, min=-1; i < 10; i++, min = -1, flag = 0) {
for (int j = 0; j < 10; j++)
if (a[j] % 2 == 0 && sel[j] == false && (min == -1 || a[j] < a[min])) {
flag = 1;
min = j;
}
if (flag == 0)
break;
else {
sel[min] = true;
cout << a[min] << " ";
}
}
}
return 0;
}
...
登录后发布评论
暂无评论,来抢沙发