文章
16
粉丝
82
获赞
1
访问
15.3k
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct stu
{
int num;
int score;
}s[];
int cmp(const void*a,const void*b)
{
struct stu *c=(struct stu*)a;
struct stu *d=(struct stu*)b;
if(c->score!=d->score)
return c->score-d->score;
else return c->num-d->num;
}
int main()
{
int n;
scanf("%d",&n);
struct stu s[n];
for(int i=0;i<n;i++)
{
scanf("%d%d",&s[i].num,&s[i].score);
}
qsort(s,n,sizeof(s[0]),cmp);
for(int i=0;i<n;i++)
{
printf("%d %d\n",s[i].num,s[i].score);
}
}
登录后发布评论
暂无评论,来抢沙发