#include<vector> #include<iostream> #include<algorithm> #include<cstdio> using namespace std; bool cmp(int a, int b) { return a < b; } bool cmp2(int a, int b) { return a > b; } int main() { int n, m; && m != )) { vector<int> ans; int t; while (n--) { cin >> t; ans.push_back(t); } ans.push_back(m); ] > ans[]) { sort(ans.begin(), ans.end(), cmp2); } else { sort(ans.begin(), ans.end(), cmp); } for (auto it = ans.begin();it != ans.end();it++) { if (it == ans.begin()) cout << *it; else cout << " " << *it; } cout << endl; } ; }
有个坑点,题目中的有序没说是降序还是升序!