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;
5万+

被折叠的 条评论
为什么被折叠?



