原题链接:[编程入门]结构体之成绩统计2
解题思路:利用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 人评分
C语言网提供由在职研发工程师或ACM蓝桥杯竞赛优秀选手录制的视频教程,并配有习题和答疑,点击了解:
一点编程也不会写的:零基础C语言学练课程
解决困扰你多年的C语言疑难杂症特性的C语言进阶课程
从零到写出一个爬虫的Python编程课程
只会语法写不出代码?手把手带你写100个编程真题的编程百练课程
信息学奥赛或C++选手的 必学C++课程
蓝桥杯ACM、信息学奥赛的必学课程:算法竞赛课入门课程
手把手讲解近五年真题的蓝桥杯辅导课程
发表评论 取消回复