//c
#include <stdio.h>
#include <stdlib.h>
struct node
{
int a,b;
};
struct node q[1001];
int cmp(const struct node *x,const struct node *y)
{
if( (*x).a < (*y).a)
return 1;
else if( (*x).a==(*y).a && (*x).b<(*y).b )
return 1;
else
return -1;
}
int main()
{
int i,n;
scanf("%d",&n);
for(i=1;i<=n;i++)
{
scanf("%d %d",&q.a,&q.b);
}
qsort(&q[1],n,sizeof(q[0]),cmp);
printf("\n");
for(i=1;i<=n;i++)
{
printf("%d %d\n",q.a,q.b);
}
return 0;
}
//cpp
//
#include <cstdio>
#include <cstdlib>
using namespace std;
struct node
{
int a,b;
};
struct node q[1001];
int cmp(const void *x,const void *y)
{
if( (*(struct node *)x).a < (*(struct node *)y).a )
return 1;
else if( (*(struct node *)x).a==(*(struct node *)y).a && (*(struct node *)x).b<(*(struct node *)y).b )
return 1;
else
return -1;
}
int main()
{
int i,n;
scanf("%d",&n);
for(i=1;i<=n;i++)
{
scanf("%d %d",&q.a,&q.b);
}
qsort(&q[1],n,sizeof(q[0]),cmp);
printf("\n");
for(i=1;i<=n;i++)
{
printf("%d %d\n",q.a,q.b);
}
return 0;
}
|