- 题目

- 思路
- 定义一个结构体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;
}
本文介绍了一个使用C语言实现的射箭比赛排名系统。通过定义一个person结构体,记录参赛者的ID和射中靶心的距离,系统能够实时更新并显示当前的冠军和菜鸟选手。代码采用标准输入输出,适用于初学者理解和实践。

被折叠的 条评论
为什么被折叠?



