返回列表 發帖
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int n[]= {5,7,3,9,8,1,2,4,6};
  4. int len=sizeof(n)/sizeof(int);
  5. bool compare(int a, int b)
  6. {
  7.     return a>b;
  8. }
  9. void show(){
  10.     cout<<"-----------------"<<endl;
  11.     for(int i: n)
  12.         cout<<i<<" ";
  13.     cout<<endl;
  14. }
  15. int main()
  16. {


  17.     show();


  18.     sort(n,n+len);
  19.     //sort(begin(n),end(n));
  20.     show();

  21.     //sort(rbegin(n),rend(n));
  22.     //sort(begin(n),end(n),greater<int>());  //less<int>()
  23.     sort(n,n+len,compare);

  24.     show();

  25.     return 0;
  26. }
複製代碼
hahahahahahahaha

TOP

返回列表