#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
#define mod 100100
using namespace std;
struct node
{
int x, y;
bool operator < (const node &a) const///重载运算
{
return x>a.x;//最小值优先
}
}ls;
int main()
{
int n;
while(~scanf("%d",&n))
{
int i;
priority_queue<node> q;
for(i = 0; i < n; i++)
{
scanf("%d %d",&ls.x,&ls.y);
q.push(ls);
}
while(!q.empty())
{
ls = q.top();
q.pop();
printf("%d %d\n",ls.x,ls.y);
}
}
return 0;
}
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
#define mod 100100
using namespace std;
struct node
{
int x, y;
bool operator < (const node &a) const///重载运算
{
return x>a.x;//最小值优先
}
}ls;
int main()
{
int n;
while(~scanf("%d",&n))
{
int i;
priority_queue<node> q;
for(i = 0; i < n; i++)
{
scanf("%d %d",&ls.x,&ls.y);
q.push(ls);
}
while(!q.empty())
{
ls = q.top();
q.pop();
printf("%d %d\n",ls.x,ls.y);
}
}
return 0;
}
本文深入探讨了排序算法和数据结构的应用,包括常见的排序算法如快速排序、归并排序等,以及数据结构如二叉树、队列、栈等在实际编程中的实践案例。
751

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



