解题思路:
注意事项:
参考代码:
import java.util.Arrays; import java.util.Comparator; import java.util.Scanner; public class T1598 { public static void main(String[] args) { Scanner in = new Scanner(System.in); while(in.hasNext()){ int n = in.nextInt(); Stu stu[] = new Stu[n]; for(int i = 0;i<n;i++){ stu[i] = new Stu(); stu[i].name = in.next(); stu[i].gender = in.next(); stu[i].age = in.nextInt(); stu[i].cj = in.nextInt(); } //构造比较器 Comparator<Stu> cj = new Comparator<Stu>(){ public int compare(Stu s1,Stu s2){ if(s1.cj >= s2.cj) return 1; return -1; } }; Arrays.sort(stu, cj); for(Stu s : stu){ System.out.println(s.toString()); } } in.close(); } } class Stu{ String name; String gender; int age; int cj; public String toString(){ String s = this.name + " " + this.gender + " " + this.age + " " + this.cj; return s; } }
0.0分
1 人评分
大神老白 (C语言代码)浏览:694 |
简单的a+b (C语言代码)浏览:764 |
C语言训练-列出最简真分数序列* (C语言代码)浏览:543 |
【亲和数】 (C语言代码)浏览:530 |
【出圈】 (C语言代码)浏览:824 |
C语言程序设计教程(第三版)课后习题5.7 (C语言代码)浏览:591 |
C语言程序设计教程(第三版)课后习题8.1 (C语言代码)浏览:573 |
蛇行矩阵 (C语言代码)浏览:560 |
IP判断 (C语言代码)浏览:592 |
找出最长的字符串来 (C语言代码)浏览:1840 |