日期:2014-05-20 浏览次数:20726 次
import java.util.Scanner; /** * Created by IntelliJ IDEA. * User: Administrator * Date: 2011-9-29 * Time: 21:45:16 * To change this template use File | Settings | File Templates. */ public class ShowNumber { public static boolean isPrimeNumber(int num){ boolean result=true; if(num==2) return true; for(int i=2;i<=num/2;i++){ if(num%i==0){ // result=false; return false; } } return result; } public static void fun(int[]a,int m) { // int i; int max=5; if(a==null){ a=new int[5]; } int primeNum=0; for(int i=m+1;primeNum<5;i++){ if(isPrimeNumber(i)){ a[primeNum]=i; primeNum++; } } } public static void main (String[] args) { System.out.println("please enter <100 numbers:"); Scanner bh=new Scanner(System.in); int m=bh.nextInt(); int []a=new int[5]; fun(a,m); for(int i=0;i<a.length;i++) System.out.print(a[i]+","); } }