import java.util.Arrays; import java.util.Comparator; import java.util.Scanner; class Stus{ int Sno; int Chinese; int Score; public Stus(int sno,int chinese,int score){ Sno=sno; Chinese=chinese; Score=score; } } public class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); Stus[]stu=new Stus[n]; for (int i = 0; i < n; i++) { int Chinese=sc.nextInt(); int Math=sc.nextInt(); int English=sc.nextInt(); stu[i]=new Stus(i+1,Chinese,Chinese+Math+English); } Arrays.sort(stu,new Comparator<Stus>(){ @Override public int compare(Stus s1, Stus s2) { if(s2.Score==s1.Score&&s2.Chinese==s1.Chinese) return s1.Sno-s2.Sno; else if(s2.Score==s1.Score) return s2.Chinese-s1.Chinese; return s2.Score-s1.Score; } }); try { for (int i = 0; i < 5; i++) System.out.println(stu[i].Sno+" "+stu[i].Score ); } catch (Exception e) { } } }
0.0分
1 人评分
C二级辅导-求偶数和 (C语言代码)浏览:626 |
C语言程序设计教程(第三版)课后习题8.1 (Java代码)浏览:778 |
2003年秋浙江省计算机等级考试二级C 编程题(1) (C语言代码)浏览:679 |
C语言训练-素数问题 (C语言代码)浏览:1654 |
C语言程序设计教程(第三版)课后习题10.1 (Java代码)浏览:1441 |
C语言训练-数字母 (C语言代码)浏览:649 |
C语言程序设计教程(第三版)课后习题8.5 (C语言代码)浏览:936 |
【亲和数】 (C语言代码)浏览:597 |
有关字符,字符串的输入输出函数说明浏览:479 |
星期判断机 (C语言代码)浏览:859 |