      1  #include <vector>
      2  #include <iostream>
      3
      4  using namespace std;
      5
      6  int main()
      7  {
      8     // Create the sieve, initially true
      9     const int sievesize = 100;
     10     vector<bool> sieve(sievesize, true);
     11     // Now search for positions with true
     12     for (int i = 2; i * i < sievesize; i++)
     13        if (sieve[i])
     14           // Strike out multiples
     15           for (int j = i + i; j < sievesize; j += i)
     16              sieve[j] = false;
     17     // Output values that remain set
     18     for (int i = 2; i < sievesize; i++)
     19        if (sieve[i])
     20           cout << i << " is prime\n";
     21     return 0;
     22  }