Eatings


私信TA

用户名:Eatings

访问量:1167

签 名:

Eatings

等  级
排  名 27347
经  验 510
参赛次数 0
文章发表 2
年  龄 20
在职情况 学生
学  校 哈尔滨华德学院
专  业 软件工程

  自我简介:

TA的其他文章

解题思路:利用String类型的二位数组,进行数据的存储,将分数最大的编号做标记,最后在数组中找到该编号的数据即可

注意事项:

参考代码:

import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n, a, b, c;
        String sno, name;
        int cursor = 0;
        int max , suma = 0, sumb = 0, sumc = 0, mid = 0;
        n = sc.nextInt();
        String[][] str = new String[n][5];
        for(int i = 0; i < n; i++){
            sno = sc.next();
            name = sc.next();
            a = sc.nextInt();
            b = sc.nextInt();
            c = sc.nextInt();
            str[i][0] = sno;
            str[i][1] = name;
            str[i][2] = String.valueOf(a);
            str[i][3] = String.valueOf(b);
            str[i][4] = String.valueOf(c);
            max = Math.max((Math.max(a,b)),c);
            if(max > mid){
                mid = max;
                cursor = i;
            }
            suma += a;
            sumb += b;
            sumc += c;
        }
        System.out.println(suma/n + " " + sumb/n + " " + sumc/n);
        System.out.println(str[cursor][0]+ " "+str[cursor][1]+" "+str[cursor][2]+" "+str[cursor][3]+" "+ str[cursor][4]);
    }
}


 

0.0分

0 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换

万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区