Page 24 -
P. 24

코드 chapter_1\prime_number
                 #include <vector>
                 #include <iostream>
                 #include <chrono>

                 using namespace std;
                 const int MaxCount = 150000;

                 bool IsPrimeNumber(int number)
                 {
                     if (number = = 1)
                         return false;
                     if (number = = 2 || number = = 3)
                         return true;
                     for (int i = 2; i < number - 1; i++)
                     {
                         if ((number % i) = = 0)
                             return false;
                     }
                     return true;
                 }

                 void PrintNumbers(const vector<int>& primes)
                 {
                     for (int v : primes)
                     {
                         cout << v << endl;
                     }
                 }

                 void main()
                 {
                     vector<int> primes;

                     auto t0 = chrono::system_clock::now();


                     for (int i = 1; i <= MaxCount; i++)
                     {
                         if (IsPrimeNumber(i))
                         {
                             primes.push_back(i);
                         }
                     }


         032
   19   20   21   22   23   24   25   26   27   28   29