import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); sc.nextLine(); int sum1, sum2, sum3, max = 0; String input; String[] split = new String[5]; String[] student = new String[5]; sum1 = sum2 = sum3 = 0; for(int i = 0; i < n; i ++) { input = sc.nextLine(); split = input.split(" "); int course1 = Integer.parseInt(split[2]); int course2 = Integer.parseInt(split[3]); int course3 = Integer.parseInt(split[4]); sum1 += course1; sum2 += course2; sum3 += course3; int sum = course1 + course2 + course3; if(max < sum) { max = sum; student = split; } } System.out.println(sum1 / n + " " + sum2 / n + " " + sum3 / n); System.out.println(student[0] + " " + student[1] + " " + student[2] + " " + student[3] + " " + student[4]); } } |
Double click to view unformatted code.