#2678: How to use sort and reverse in c++? i can show you


1752786-4@g.puiching.edu.mo (林敬晉P5A08(JalenLam_progamer)(IQ...)

School : Pui Ching Middle School
ID : 3260
IP address : [192.168.120.33]
Last Login :
2025-06-05 11:37:15
. Unfinished! | From: [192.168.120.33] | Post Date : 2025-07-01 17:57

 

// step 1:

// make a vector

#include<bits/stdc++.h>

using namespace std;

int main(){

    vector<int> a(4) = {3,4,2,1};

// step 2:

// if you need sort

// if you need a[i]>a[i+1]

    sort(a.begin(),a.end(),great<int>());

// if you need a[i]<a[i+1]

    sort(a.begin(),a.end(),less<int>());

 

// if you need reverse

    reverse(a.begin(),a.end());

}

 
ZeroJudge Forum