当前位置:网站首页>Returns the subscript after array sorting

Returns the subscript after array sorting

2022-04-23 14:14:00 Stingy old Sao

#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>

using namespace std;
int a[3]={3,1,2};
bool cmp(int i,int j){
    return a[i]<a[j];
}

int main()
{
    int b[3];

    iota(b,b+3,0);
    sort(b,b+3,cmp);
    for (int x:b) {
        cout<<x<<" ";
    }
    cout<<endl;
    return 0;
}

版权声明
本文为[Stingy old Sao]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231407093612.html