找最高
Time Limit: 1000MS Memory Limit: 65536KB
Submit Statistic
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
import java.util.Scanner;
public class Main {
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
int max = -1;
String ss = "";
int hh = 0, ww = 0;
while(n > 0)
{
String s;
int h, w;
s = scan.next();
h = scan.nextInt();
w = scan.nextInt();
if(h > max)
{
max = h;
ss = s;
hh = h;
ww = w;
}
n--;
}
System.out.print(ss);
System.out.print(" ");
System.out.print(hh);
System.out.print(" ");
System.out.print(ww);
}
}
/***************************************************
User name: worryAnswer
Result: Accepted
Take time: 184ms
Take Memory: 12136KB
Submit time: 2018-01-30 21:24:27
****************************************************/