标题: 键盘录入5个学生信息 [打印本页] 作者: 林明辉 时间: 2016-4-23 22:55 标题: 键盘录入5个学生信息 public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("请输入姓名,语文成绩,数学成绩,英语成绩");
TreeSet<String> ts = new TreeSet<>(new Comparator<String>() {
@Override
public int compare(String s1, String s2) {
int num = s1.compareTo(s2);
return num==0 ? 1:num;
}
});
while (ts.size()<5) {
String line = sc.nextLine();
String[]arr = line.split(",");
int chinese = Integer.parseInt(arr[1]);
int math = Integer.parseInt(arr[2]);
int english = Integer.parseInt(arr[3]);