java 题目:有三个学生,每个学生有五门课程的成绩,从键盘输入以下数据:学生号,五门课程成绩。
答案:1 悬赏:70 手机版
解决时间 2021-03-24 22:07
- 提问者网友:活着好累
- 2021-03-23 23:33
java 题目:有三个学生,每个学生有五门课程的成绩,从键盘输入以下数据:学生号,五门课程成绩。
最佳答案
- 五星知识达人网友:执傲
- 2021-03-24 00:56
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String [][] arrs = new String[3][6];
for (int i = 0; i System.out.println("请输入第"+(i+1)+"学生号!");
String stuID = input.next();
arrs[i][0] = stuID;
for (int j = 1; j System.out.println("请输入第"+j+"门课成绩!");
int grade = input.nextInt();
if(grade<0){
System.out.println("输入有误,请重新输入第"+j+"门课成绩!");
}
arrs[i][j] = grade+"";
}
}
for (int i = 0; i < arrs.length; i++) {
for (int j = 0; j < arrs[i].length; j++) {
System.out.print(arrs[i][j]+" ");
}
System.out.println();
}
System.out.println("--------------------------------");
for (int i = 1; i < arrs[0].length; i++) {
int [] index = {i};
sort(arrs,index);
System.out.println("第"+i+"门的成绩最好的学号为:"+arrs[2][0]);
}
}
public static void sort(String[][] ob, final int[] order) {
Arrays.sort(ob, new Comparator
Scanner input = new Scanner(System.in);
String [][] arrs = new String[3][6];
for (int i = 0; i System.out.println("请输入第"+(i+1)+"学生号!");
String stuID = input.next();
arrs[i][0] = stuID;
for (int j = 1; j System.out.println("请输入第"+j+"门课成绩!");
int grade = input.nextInt();
if(grade<0){
System.out.println("输入有误,请重新输入第"+j+"门课成绩!");
}
arrs[i][j] = grade+"";
}
}
for (int i = 0; i < arrs.length; i++) {
for (int j = 0; j < arrs[i].length; j++) {
System.out.print(arrs[i][j]+" ");
}
System.out.println();
}
System.out.println("--------------------------------");
for (int i = 1; i < arrs[0].length; i++) {
int [] index = {i};
sort(arrs,index);
System.out.println("第"+i+"门的成绩最好的学号为:"+arrs[2][0]);
}
}
public static void sort(String[][] ob, final int[] order) {
Arrays.sort(ob, new Comparator
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯