import java.util.Scanner;
public class PAT1004 {
public static void main(String[] args) {
Scanner scanner=new Scanner(System.in);
int length=Integer.parseInt(scanner.nextLine());
String[] name=new String[length];
String[] number=new String[length];
Integer[] score=new Integer[length];
for(int i=0;i<length;i++) {
String str=scanner.nextLine();
String[] s=str.split(" ");
name[i]=s[0];
number[i]=s[1];
score[i]=Integer.valueOf(s[2]);
}
int MaxScore=score[0];int MaxIndex=0;
int MinScore=score[0];int MinIndex=0;
for(int i=0;i<length;i++) {
if(score[i]>MaxScore) {
MaxScore=score[i];
MaxIndex=i;
}
if(score[i]<MinScore) {
MinScore=score[i];
MinIndex=i;
}
}
String s1=name[MaxIndex]+" "+number[MaxIndex];
String s2=name[MinIndex]+" "+number[MinIndex];
System.out.println(s1);
System.out.println(s2);
}
}
踩过的坑:
1、收集Scanner的int型数据的时候,不要int i=scanner.nextInt(); 要 int length=Integer.parseInt(scanner.nextLine());
我在自己的编译器上没问题,但是在PAT上测试就莫名过不去