解题代码
#include<cstdio>
#include<cstring>
#include<cmath>
char upper[5], lower[5], temp[5];
double mmin = 200, mmax = 0, dis;
int n, x, y;
int main() {
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%s%d%d", temp, &x, &y);
dis = sqrt(1.0*x*x + 1.0*y*y);
if (dis > mmax) {
mmax = dis;
strcpy(lower , temp);
}
if (dis < mmin) {
mmin = dis;
strcpy(upper, temp);
}
}
printf("%s %s", upper, lower);
return 0;
}
测试结果
问题整理
1.基础题目。