找最高
Time Limit: 1000MS
Memory Limit: 65536KB
Problem Description
给定 n 个人的姓名、身高以及体重,你需要找出身高最高的人,并输出他的信息。
Input
第 1 行输入 1 个整数 n (1 <= n <= 5) 表示人数。
接下来 n 行,每行按照 "s h w" 的格式输入一个人的信息,其中 s(不包含空格且长度不超过 10 的字符串)表示姓名,h (100 <= h <= 300) 表示身高,w (20 <= w <= 200) 表示体重。
输入保证没有重复的身高。
Output
输出 1 行,表示最高的人的信息,格式和输入信息相同。
Example Input
3 Alice 150 60 Bob 180 70 Clark 165 60
Example Output
Bob 180 70
Hint
Author
【2016级《程序设计基础(B)II》期末上机考试-补测】bLue
#include <stdio.h>
#include <string.h>
#include <math.h>
struct node
{
char name[12];
int h,w;
}a[10];
int main()
{
int n,i,max1 = -1,j;
scanf("%d",&n);
for(i = 0;i <n;i++)
{
scanf("%s%d%d",a[i].name,&a[i].h,&a[i].w);
if(max1 < a[i].h)
{
max1 = a[i].h;
j = i;
}
}
printf("%s %d %d\n",a[j].name,a[j].h,a[j].w);
return 0;
}
1072

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



