62,614
社区成员
发帖
与我相关
我的任务
分享
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = Integer.parseInt(in.nextLine());
List<Student> list = new ArrayList<Student>();
for (int i = 0; i < n; i++)
list.add(new Student(in.nextLine()));
System.out.println(Collections.max(list));
System.out.println(Collections.min(list));
}
}
class Student implements Comparable<Student> {
String name;
String number;
int score;
Student(String str) {
String[] s = str.split(" ");
name = s[0];
number = s[1];
score = Integer.parseInt(s[2]);
}
@Override
public String toString() {
return new StringBuffer(name).append(" ").append(number).toString();
}
@Override
public int compareTo(Student o) {
return score - o.score;
}
}