标签:ati static rgs false int logs 筛法求素数 pre style
1 using System; 2 public class PrimeFilter{ 3 public static void Main( string [] args ){ 4 int N = 100; 5 bool [] a = new bool[N+1]; 6 for( int i=2; i<=N; i++ ) a[i]=true; 7 8 for( int i=2; i<N; i++ ) 9 { 10 if(a[i]) for( int j=i*2; j<=N; j+=i ) 11 a[j]=false; 12 } 13 14 for( int i=2; i<=N; i++) 15 if( a[i] ) Console.Write( i + " " ); 16 } 17 }
标签:ati static rgs false int logs 筛法求素数 pre style
原文地址:http://www.cnblogs.com/xyzyj/p/6536163.html