c++ Programming Glossary: primes.push_back
Printing prime numbers from 1 through 100 http://stackoverflow.com/questions/5200879/printing-prime-numbers-from-1-through-100 return 0 3. #include vector int main std vector int primes primes.push_back 2 for int i 3 i 100 i bool prime true for int j 0 j primes.size.. j i j if i primes j 0 prime false break if prime primes.push_back i cout i return 0 Edit In the third example we keep track of..
Porting optimized Sieve of Eratosthenes from Python to C++ http://stackoverflow.com/questions/5293238/porting-optimized-sieve-of-eratosthenes-from-python-to-c sievemax 1 boost dynamic_bitset sieve sievemax sieve.set primes.push_back 2 for i 0 i sievemaxroot i if sieve i primes.push_back 2 i.. primes.push_back 2 for i 0 i sievemaxroot i if sieve i primes.push_back 2 i 3 for T j 3 i 3 j sievemax j 2 i 3 sieve j 0 filter multiples.. 3 sieve j 0 filter multiples for i sievemax i if sieve i primes.push_back 2 i 3 This implementation is decent and automatically skips..
|