几处排序函数

c快速排序qsort
int cmp(const void * a,const void * b){
    int * aa=(int *)a;
    int * bb=(int *)b;
    return (*aa)-(*bb);
}按从小到大排列!


c++中sort函数

template <class RandomAccessIterator>
  void sort ( RandomAccessIterator first, RandomAccessIterator last );

template <class RandomAccessIterator, class Compare>
  void sort ( RandomAccessIterator first, RandomAccessIterator last, Compare comp );

Parameters

first, last
Random-Access iterators to the initial and final positions of the sequence to be sorted. The range used is [first,last), which contains all the elements between first and last, including the element pointed by first but not the element pointed by last.
comp
Comparison function object that, taking two values of the same type than those contained in the range, returns true if the first argument goes before the second argument in the specific strict weak ordering it defines, and false otherwise.

bool cmp (int i,int j) { return (i<j); }   //定义从小到大的顺序

c++ priority_queue

通过操作,按照元素从大到小的顺序出队

struct Status  
{  
    int ti;  
    int di;  
    bool operator <(const Status a)const  
    {  
        return ti<a.ti;  
    }  
}trap[N],now,temp;  
priority_queue<Status>q;



评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值