?? ex030211.java
字號:
import java.io.*;
public class Ex030211{
static boolean isPrimeNumber(int x){
if (x==1)
return false;
for (int i=2; i<x;i++){
if (x%i==0){
return false;
}
}
return true;
}
public static void main(String[] args){
int x=0;
Reader ir = new InputStreamReader(System.in);
BufferedReader r = new BufferedReader(ir);
String sc="";
System.out.print(" x = ");
try{
sc = r.readLine();
}catch (IOException e){}
try{
x=Integer.parseInt(sc);
}catch (NumberFormatException e){
System.out.println("輸入的數據不是整數");
System.exit(1);
}
if (isPrimeNumber(x))
System.out.println(""+x+" is a Prime Number");
else
System.out.println(""+x + " is not a Prime Number");
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -