解题思路:
注意事项:
参考代码:
import java.util.*; import java.math.*; public class Main { public static void main(String[] args){ Scanner sc=new Scanner(System.in); Scanner sc2=new Scanner(System.in); int n=sc.nextInt(); TreeSet<Student> ts=new TreeSet<>(); for(int i=0;i<n;i++){ ts.add(new Student(sc.next(),sc.next(),sc.nextInt(),sc.nextInt(),sc.nextInt())); } Iterator lt=ts.iterator(); int a=0,b=0,c=0; while(lt.hasNext()){ Student tmp=(Student) lt.next(); a+=tmp.a; b+=tmp.b; c+=tmp.c; } System.out.println(a/n+" "+b/n+" "+c/n); System.out.println(ts.first()); } } class Student implements Comparable<Student>{ String number; String name; int a; int b; int c; int d; public Student(String number,String name,int a,int b,int c){ this.number=number; this.name=name; this.a=a; this.b=b; this.c=c; this.d=a+b+c; } public int compareTo(Student s){ int num=s.d-this.d; return num==0?1:num; } public String toString(){ return number+" "+name+" "+a+" "+b+" "+c; } }
0.0分
0 人评分
C语言程序设计教程(第三版)课后习题11.1 (C语言代码)浏览:822 |
奖学金 (C++代码)浏览:2056 |
回文数(一) (C语言代码)浏览:809 |
C语言程序设计教程(第三版)课后习题8.6 (C语言代码)浏览:631 |
C语言程序设计教程(第三版)课后习题7.1 (C语言代码)浏览:1267 |
WU-输入输出格式练习 (C++代码)浏览:1134 |
C语言程序设计教程(第三版)课后习题1.6 (C语言代码)浏览:689 |
C二级辅导-统计字符 (C语言代码)浏览:514 |
简单的a+b (C语言代码)浏览:683 |
第三届阿里中间件性能挑战赛-总决赛亚军比赛攻略浏览:1170 |