runtime error

2j1ejyu Reply 6 years 2 weeks ago
import java.util.Arrays; import java.util.*; public class Main { public static void main(String[] args) { Scanner input = new Scanner(System.in); int C = input.nextInt(); students students[] = new students[C]; for(int i=0; i<C; i++){ students[i] = new students(input.nextInt()); for(int j=0; j<students[i].N; j++){ students[i].scores[j]=input.nextInt(); } students[i].setpercentage(); } for(int i=0; i<C; i++){ System.out.printf("%.3f",students[i].percent); if(i<C-1) System.out.println(); } } } class students{ int N; int scores[] = new int[N]; double percent; public students(){} public students(int k){ N=k; } public void setpercentage(){ int k=0; double sum=0; for(int i=0; i<N; i++){ sum += scores[i]; } for(int i=0; i<N; i++){ if(scores[i]>sum/N) k++; } percent= Math.floor((double)1000*k/N)/1000.0; } } 어디서 문제가 생겼나요?
Hyunwoo Reply 6 years 1 week ago
14번째줄인 students[i].scores[j]=input.nextInt() 에서 runtime error가 생겼습니다.
2j1ejyu Reply 6 years 1 week ago
저도 그건 확인했으나 거기에 왜 에러가 떴는지 모르겠습니다.