package pinduoduo;
import java.util.Scanner;
public class Demo2 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int[] scores = new int[5];
for (int i = 1; i <= 5; i++) {
System.out.println("请输入第"+i+"位学生的成绩");
int a = sc.nextInt();
scores[i-1] = a;
}
int max = scores[0];
for (int i =1 ; i < scores.length; i++) {
if(scores[i]>max) {
max = scores[i];
}
}
System.out.println("最高分为:"+max);
}
}
Java程序:输入五位学生成绩并找出最高分
这是一个Java程序,用于接收用户输入的五位学生分数,并通过循环遍历找出最高分。程序首先创建一个整型数组存储成绩,然后依次读取每个学生的分数并更新最高分变量。最后,程序输出最高分数。
2340

被折叠的 条评论
为什么被折叠?



