# 1082 Shooting Match PAT (Basic Level)

Posted on

https://pintia.cn/problem-sets/994805260223102976/problems/994805260990660608

Analysis:

This is a typical topic that gives the number and score and then outputs the highest and lowest score, but the score is calculated by X and y.

I use character array to store the number of athletes, which is universal, but this question guarantees that the number is 4 digits, so I can also use integer variables to save, but we should consider the form of% 04D when output.

If you use character arrays, you need to consider that there may be redundant blank characters between the input string and the input integer, which can be filtered through%*c.

According to the distance formula between two points in the plane, R can be obtained.2=x2+y2Considering R2The size relation can represent the size relation of r, so calculate R directly.2Avoid using sqrt () functions.

AC Code:

``````#include
#include

int main(void)
{
int n=0,x=0,y=0,min=88888,max=-1;
char s="",s1="",s2="";
scanf("%d",&n);
while(n--)
{
scanf("%*c%s%d%d",s,&x,&y);
x=x*x+y*y;
if(xmax)
max=x,strcpy(s2,s);
}
printf("%s %s",s1,s2);
return 0;
}``````