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语言代码)浏览:723 |
C语言训练-自守数问题 (C语言代码)浏览:741 |
C语言训练-求矩阵的两对角线上的元素之和 (C语言代码)浏览:932 |
Tom数 (Java代码)浏览:587 |
P1003 (Java代码)浏览:755 |
A+B for Input-Output Practice (IV) (C++代码)浏览:524 |
C语言程序设计教程(第三版)课后习题1.6 (C语言代码)浏览:473 |
问题1458错误票据 唯一题解!!!!!浏览:899 |
WU-Sine之舞 (C++代码)(蓝桥杯历年真题解析 一天一题)(唯一题解!!!)浏览:888 |
最长字符串 (C语言代码)浏览:790 |