优先队列和排序的不同

#include"iostream"
#include"algorithm"
#include"queue"
using namespace std;
const int maxn=5e4+5;
struct AAA
{
    int t;
    bool operator<(const AAA &a)const
    {
        return t<a.t;
    }
};
int main()
{
    priority_queue<AAA>que;
    AAA a[10]={1,2,3,6,5,4};
    for(int i=0;i<6;i++)que.push(a[i]);
    while(!que.empty())
    {
        cout<<que.top().t<<" ";
        que.pop();
    }
    cout<<"\n";
    sort(a,a+6);
    for(int i=0;i<6;i++)cout<<a[i].t<<" ";

}

 

posted on 2018-03-24 20:43  血腥刽子手  阅读(246)  评论(0编辑  收藏  举报

导航