标签:style blog java color for div
1 import java.util.Scanner; 2 3 /** 4 * Created by Administrator on 14-5-20. 5 */ 6 public class Sieve { 7 public static void main(String[] args){ 8 Scanner scanner=new Scanner(System.in); 9 String str=scanner.nextLine(); 10 int num=Integer.parseInt(str); 11 int[] init=new int[num+1]; 12 int[] result =new int[num+1]; 13 for(int i=2;i<num+1;i++) 14 init[i]=i; 15 for(int i=2;i<java.lang.Math.sqrt(num);i++){ 16 int p=init[i]; 17 if(p!=0) { 18 int j = p*p; 19 while(j<=num){ 20 if(init[j]!=0) 21 init[j]=0; 22 j=j+p; 23 } 24 } 25 } 26 int j=0; 27 for(int i=2;i<num;i++){ 28 if(init[i]!=0) 29 result[j++]=init[i]; 30 } 31 for(int i=0;i<j;i++){ 32 System.out.println(result[i]); 33 } 34 } 35 }
标签:style blog java color for div
原文地址:http://www.cnblogs.com/mingcaoyouxin/p/3842135.html