- 题目
- 思路
- 定义一个结构体person,设置冠军和菜鸟的初始离靶心距离,边输入边更新冠军和菜鸟的id
#include <stdio.h>
struct person{
int id,x,y;
int d;
}temp,win,lost;
int main(){
int n;
scanf("%d",&n);
lost.d=0;
win.d=10001;
for(int i=0;i<n;i++){
scanf("%d %d %d",&temp.id,&temp.x,&temp.y);
temp.d=temp.x*temp.x+temp.y*temp.y;
if(temp.d>lost.d){
lost.id=temp.id;
lost.d=temp.d;
}
if(temp.d<=win.d){
win.id=temp.id;
win.d=temp.d;
}
}
printf("%04d %04d",win.id,lost.id);
return 0;
}