标题:STL中sort排序问题
取消只看楼主
也许等直到
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2016-2-25
结帖率:33.33%
 问题点数:0 回复次数:0 
STL中sort排序问题
求大神指点一下,我记得有这种方法使用sort()可以按自己的需求进行排序的呀?还有这个排序是怎么实现的,为什么返回真假值就可以实现排序呢?
#include <iostream>
#include <vector>
#include<queue>
#include<stack>
#include<list>
#include<algorithm>

using namespace std;
bool cmp(const int a, const int b)
{
    return a > b;
}
int main()
{   
    stack<int>s;
    vector<int>v;
    v.push_back(2);
    v.push_back(3);
    v.push_back(1);
    sort(v.begin(), v.end());
    for (int i = 0; i < 3; i++)
    {
        cout << v[i] << " ";
    }
    cout << endl;
    return 0;
}
搜索更多相关主题的帖子: return include 
2016-03-13 18:23



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-462447-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.092976 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved