69,371
社区成员
发帖
与我相关
我的任务
分享
#include <search.h>
typedef struct point
{
int s;
int x;
int y;
}Point;
Point *ps;
int i, n;
int cmp(Point *p1, Point *p2)
{
if (p1->x < p2->x) return 0;
else if (p1->x > p2->x) return 1;
else return p1->y > p2->y;
}
int main()
{
scanf("%d", &n);
ps = malloc(sizeof(Point)*n);
i = 0;
//读入坐标
while (i < n)
{
scanf("%d%d%d", &ps[i].s, &ps[i].x, &ps[i].y);
i++;
}
qsort(ps, n, sizeof(Point), cmp);
for (i = 0; i < n; i++) printf("%d ", ps[i].s);
printf("\n");
free(ps);
return 0;
}