解题思路:
注意事项:
参考代码:
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;
public class Main {
static class student{
String name="";
String sex;
int age;
int cj;
public String toString() {
String s=this.name+" "+this.sex+" "+this.age+" "+this.cj;
return s;
}
}
public static void main(String[] args) {
Scanner scanner=new Scanner(System.in);
int n=scanner.nextInt();
student[] stu=new student[n];
for(int i=0;i<n;i++) {
stu[i]=new student();
stu[i].name=scanner.next();
stu[i].sex=scanner.next();
stu[i].age=scanner.nextInt();
stu[i].cj=scanner.nextInt();
}
Comparator<student> cj=new Comparator<student>() {
public int compare(student o1, student o2) {
// TODO Auto-generated method stub
if(o1.cj>=o2.cj)
return 1;
return -1;
}
};
Arrays.sort(stu, cj);
for(student s:stu)
System.out.println(s.toString());
}
}
0.0分
0 人评分