要求用java程序回答 50
2020-05-09
展开全部
import java.util.Arrays;
import java.util.Scanner;
public class ScoreTest {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("请输入 n: ");
int n = scanner.nextInt();
int[] a = new int[n];
int sum = 0;
for (int i = 1; i <= n; i++) {
System.out.println("请输入第 " + i + " 个学生成绩:");
a[i - 1] = scanner.nextInt();
sum += a[i - 1];
}
System.out.println("输入的成绩: " + Arrays.toString(a));
System.out.println("平均成绩: " + sum / a.length);
}
}
import java.util.Scanner;
public class ScoreTest {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("请输入 n: ");
int n = scanner.nextInt();
int[] a = new int[n];
int sum = 0;
for (int i = 1; i <= n; i++) {
System.out.println("请输入第 " + i + " 个学生成绩:");
a[i - 1] = scanner.nextInt();
sum += a[i - 1];
}
System.out.println("输入的成绩: " + Arrays.toString(a));
System.out.println("平均成绩: " + sum / a.length);
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询