pat 乙级1082 射击比赛(c语言实现)

#include
#include
typedef struct d
{
int id;
int grade;
}man;
int cmp(const void*a,const void*b)
{
man s1=*(man*)a;
man s2=*(man*)b;
return s1.grade-s2.grade;
}
main()
{
int n;
man a[10002];
int x,y,max=0,min=999999;
scanf("%d",&n);
for(int j=0;j {
scanf("%d%d%d",&a[j].id,&x,&y);
a[j].grade=x*x+y*y;
}
qsort(a,n,sizeof(man),cmp);
printf("%04d %04d",a[0].id,a[n-1].id);


https://www.patest.cn/contests/pat-b-practise/1082

你可能感兴趣的:(pat)