#2194: ans


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
b266. 排序問題(1) | From: [192.168.120.33] | Post Date : 2025-06-02 14:19

use sort function

 
#2677: Re:ans


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
b266. 排序問題(1) | From: [192.168.120.33] | Post Date : 2025-07-01 17:54

use sort function


in c++ how to use sort? i can show you

 

 

 

 

// step 1:

// make a vector

#include<bits/stdc++.h>

using namespace std;

int main(){

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

// step 2:

// use sort function

// 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