#include <cstdio>
#include <algorithm>
#define PAUSE system("pause")
#define PLINE printf("-----------\n")
using namespace std;
#define N 1000005
struct Node
{
int x, y;
}a[1000];
int cmp(const void* a, const void* b)
{
Node* p = (Node*)a;
Node* q = (Node*)b;
if(p->x != q->x)
return p->x > q->x;
return p->y < q->y;
}
int cmp2(const void* a, const void* b)
{
Node* p = (Node*)a;
Node* q = (Node*)b;
if(p->x != q->x)
return q->x - p->x;
return p->y - q->y;
}
void bubblesort(int begin, int end, int (*fcmp)(const void*, const void*))
{
for(int i=begin; i<end; i++)
for(int j=i+1; j<end; j++)
if(fcmp(&a[j], &a[i]))
swap(a[i], a[j]);
}
int main()
{
int n;
scanf("%d", &n);
for(int i=0; i<n; i++)
scanf("%d%d", &a[i].x, &a[i].y);
bubblesort(0, n, cmp2);
PLINE;
for(int i=0; i<n; i++)
printf("%d %d\n", a[i].x, a[i].y);
PAUSE;
return 0;
}
swap是库函数,交换两个数的值