#21307: 一直報NA 自己執行都是對的


aw52052001 (roger)

學校 : 桃園市私立新興高級中學
編號 : 66471
來源 : [101.12.70.63]
最後登入時間 :
2021-03-21 11:03:42
b964. 1. 成績指標 -- 2016年3月apcs | From: [101.14.154.191] | 發表日期 : 2020-05-14 18:25

您的程式被監控系統中斷,可能是程式無法正常結束所導致。
Error: Could not find or load main class base_java
Exception in thread "main" java.util.NoSuchElementException: No line found
	at java.util.Scanner.nextLine(Scanner.java:1540)
	at JAVA.main(JAVA.java:9)


import java.util.Scanner; public class JAVA{ public static void main(String[] args){ Scanner cin= new Scanner(System.in); while (cin.hasNext()){ Scanner r =new Scanner(System.in); int n = cin.nextInt(); String[] grade1 = r.nextLine().split(" "); int[] grade = new int[n]; for(int i=0;i < n;i++){ grade[i] = Integer.parseInt(grade1[i]); } int small,na = 0,nu = 0; for(int i=0;i<n;i++){ for(int j=0;j < n - 1;j++){ if(grade[j] > grade[j+1]){ small=grade[j+1]; grade[j+1] = grade[j]; grade[j] = small; } } } int hei = grade[n-1]; int low = grade[0]; for(int i=0;i < n;i++){ if(grade[i] >= 60){ if(grade[i] < hei){ hei = grade[i]; } nu++; }else{ if(grade[i] > low){ low = grade[i]; } na++; } } for(int i=0;i < n;i++){ System.out.print(grade[i]+" "); } System.out.println(""); if(na ==0){ System.out.println("best case"); }else System.out.println(low); if(nu == 0){ System.out.println("worst case"); }else System.out.println(hei); } } }
 
ZeroJudge Forum