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语言代码)浏览:694 |
C语言训练-斐波纳契数列 (C语言代码)浏览:1174 |
C语言程序设计教程(第三版)课后习题4.9 (C语言代码)浏览:1523 |
多输入输出练习1 (C语言代码)浏览:1189 |
C语言程序设计教程(第三版)课后习题1.5 (C++代码)浏览:759 |
数组输出 (C语言代码)--此题的题目描述有问题浏览:1817 |
C语言程序设计教程(第三版)课后习题5.7 (Java代码)浏览:889 |
WU-蓝桥杯算法提高VIP-企业奖金发放 (C++代码)浏览:1176 |
DNA (C语言描述,数据结构)浏览:862 |
C语言程序设计教程(第三版)课后习题10.2 (C语言代码)浏览:690 |