sort升序降序排列

 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 void basicSort(){
 4     vector<int> nums{3,5,2,1,6,9,7};
 5     sort(nums.begin(),nums.end());
 6     cout<<"升序";
 7     for(int n:nums) cout<<n<<" ";
 8     cout<<endl;
 9     sort(nums.rbegin(),nums.rend());
10     cout<<"降序";
11     for(int n:nums) cout<<n<<" ";
12 }
13 int main(int argc, char** argv) {
14     basicSort();
15     return 0;
16 }

 

posted @ 2025-07-26 14:59  黛玉醉打将门神  阅读(5)  评论(0)    收藏  举报