注意事项:细节
参考代码:
#include<bits/stdc++.h> using namespace std; bool gre(int x, int y) { return x> y; } int main() { int a[10]; while (scanf("%d",&a[0])!=EOF) { for (int i = 1; i < 10; i++) { cin >> a[i]; } sort(a, a + 10, gre); for (int i = 0; i < 10; i++) { if (a[i] % 2 != 0) cout << a[i] << " "; } for (int i = 9; i >= 0; i--) { if (a[i] % 2 == 0) cout << a[i]; if (a[i] % 2 == 0 && i > 0) cout << " "; } cout << endl; } }
0.0分
8 人评分