1 题目
2 代码
import java.util.Scanner;
public class B1004 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
String gStudentName = "";
String bStudentName = "";
String gStudentId = "";
String bStudentId = "";
int gStudentScore = -1;
int bStudentScore = 100;
String x = "";
String y = "";
int z = 0;
for (int i = 0; i < n; i++) {
x = sc.next();
y = sc.next();
z = sc.nextInt();
if (z > gStudentScore){
gStudentName = x;
gStudentId = y;
gStudentScore = z;
}
if(z < bStudentScore){
bStudentName = x;
bStudentId = y;
bStudentScore = z;
}
}
System.out.println(gStudentName+" "+gStudentId);
System.out.println(bStudentName+" "+bStudentId);
}
}
3 要点
(1)代码有点不好看,可以用类来做可能更合适。