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语言代码)浏览:492 |
C语言程序设计教程(第三版)课后习题11.1 (C语言代码)浏览:676 |
2003年秋浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:746 |
C语言程序设计教程(第三版)课后习题5.4 (C语言代码)浏览:1294 |
Wu-求圆的面积 (C++代码)浏览:1883 |
【绝对值排序】 (C语言代码)浏览:820 |
打印十字图 (C语言代码)浏览:2701 |
C语言程序设计教程(第三版)课后习题10.3 (C语言代码)浏览:1908 |
蛇行矩阵 (C语言代码)浏览:498 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:463 |