java如何按顺序显示输入的分数?
import java.util.Scanner;
public class Score {
int num = 0;//students
int score = 0;//score
int[] arr = new int[num];
public int student() {
Scanner scan = new Scanner(System.in);
System.out.println("Number of students");
num = scan.nextInt();
int[] arr = new int[num];
for (int i = 0; i < num; i++) {
arr[i] = scan.nextInt();
score = arr[i];
System.out.println(i + 1 + "students socre : " + score);
}
return score;
}
public void list() {
int[] arr = new int[num];
for (int i = 0; i < num; i++) {
//arr[i]=score;
System.out.println(+score);
}
}
public static void main(String[] args) {
Score a = new Score();
a.student();
a.list();
}
}
如果我输入5名学生的分数为10、20、30、40、50, 所以我想展示一下
1 students socre : 10 2 students socre : 20 3 students socre : 30 4 students socre : 40 5 students socre : 50
and
10 20 30 40 50
但我的代码显示
1 students socre : 10 2 students socre : 20 3 students socre : 30 4 students socre : 40 5 students socre : 50
and
50 50 50 50 50
共 (0) 个答案