优先队列-优先级别

#include<stdio.h>
#include<cstring>
#include<queue>
#include<math.h>
#include<algorithm>

using namespace std;
const int maxn=1007;

int main()
{
    int T;
    scanf("%d", &T);

    while(T--)
    {
        int n,  num;
        scanf("%d", &n);
        ///优先输出大数据
        priority_queue<int >que;
        for(int i=0; i<n; i++)
        {
            scanf("%d", &num);
            que.push(num);
        }
        while(que.size())
        {
            printf("%d ", que.top());
            que.pop();
        }
        printf("\n");
        ///优先输出小数据
        priority_queue<int, vector<int>, greater<int> >Q;
        for(int i=0; i<n; i++)
        {
            scanf("%d", &num);
            Q.push(num);
        }
        while(Q.size())
        {
            printf("%d ", Q.top());
            Q.pop();
        }
        printf("\n");
    }
    return 0;
}

 

posted @ 2017-04-26 15:31  爱记录一切美好的微笑  阅读(158)  评论(0编辑  收藏  举报