解题思路:
注意事项:
参考代码:
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语言程序设计教程(第三版)课后习题7.2 (Java代码)浏览:686 |
钟神赛车 (C++代码)浏览:866 |
C语言训练-数字母 (C语言代码)浏览:585 |
C语言训练-最大数问题 (C语言代码)浏览:633 |
Pascal三角 (C语言代码)格式错误浏览:521 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:476 |
蛇行矩阵 (C语言代码)浏览:536 |
C语言程序设计教程(第三版)课后习题9.8 (C语言代码)浏览:616 |
简单的a+b (C语言代码)浏览:443 |
A+B for Input-Output Practice (IV) (C语言代码)浏览:471 |