U E D R , A S I H C RSS

소수구하기/영록

1 부터 50000까지 소수 구하기..
~cpp 
#include <iostream> 
using namespace std; 
#include <ctime> 
 
void main() 
{ 
		clock_t start = clock(); 
        int counter = 0; 
                for(int i = 1; i <= 50000; i++) 
                { 
                        counter=0; 
                        for (int j = 1; j <= i; j++) 
                        {                                
                                if(i%j == 0) 
                                        counter++; 
                        } 
                 if (counter == 2) 
                        cout << i << "\n"; 
                } 
		clock_t end = clock() - start; 
        cout << (double)end/CLOCKS_PER_SEC << "초\n"; 

}   68.77 초라니........ 절망........ 

 영동이의 도움으로 겨우겨우 짤수 있었다는..... ㅠ_ㅠ

-_-;; 시간은 못 줄이겠고.... 암튼. 엄청느리게 출력되는 허접한 소스.. -_-;
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:30:13
Processing time 0.0196 sec