您的程式被監控系統中斷,可能是程式無法正常結束所導致。 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); } } }