0_0_39655042_9966\Main.java:1: 错误: 解析时已到达文件结尾
import java.util.Scanner;public class Main{public static void main(String[] args) {Scanner input = new Scanner(System.in);while (true) {int x = input.nextInt();int y = input.nextInt();if (x == 0 && y == 0) {break;}boolean allPrimes = true;for (int n = x; n <= y; n++) { //调用isPrimeint value = n * n + n + 41;if (!isPrime(value)) {allPrimes = false;break;}}System.out.println(allPrimes ? "OK" : "Sorry");}}//判断是否素数public static boolean isPrime(int num) {for (int i = 2; i <= num/2; i++) {if (num % i == 0) {return false;}}return true;}}
^
0_0_39655042_9966\Main.java:1: 错误: 解析时已到达文件结尾
import java.util.Scanner;public class Main{public static void main(String[] args) {Scanner input = new Scanner(System.in);while (true) {int x = input.nextInt();int y = input.nextInt();if (x == 0 && y == 0) {break;}boolean allPrimes = true;for (int n = x; n <= y; n++) { //调用isPrimeint value = n * n + n + 41;if (!isPrime(value)) {allPrimes = false;break;}}System.out.println(allPrimes ? "OK" : "Sorry");}}//判断是否素数public static boolean isPrime(int num) {for (int i = 2; i <= num/2; i++) {if (num % i == 0) {return false;}}return true;}}
^
2 个错误
|