参考代码:
#include<bits/stdc++.h> using namespace std; int main() { int n; int a[10]; stack<int> fin; int x; cin >> n; for (int k = 0; k < n; k++) { for (int i = 0; i < 9; i++) { cin >> a[i]; } for (int i = 8; i>0; i--) { if (a[i] > a[0]) fin.push(a[i]); } fin.push(a[0]); for (int i = 0; i<9; i++) { if (a[i] < a[0]) fin.push(a[i]); } while (fin.size()) { cout << fin.top(); fin.pop(); if (fin.size() != 0)cout << " "; else cout << endl; } } }
0.0分
4 人评分