#include <vector>
#include <iostream>

int main()
{
    using namespace std;

    unsigned const N = 1000;

    vector<pair<int, bool> > vec(N - 1); // Platz. Erster Wert ist die Zahl, der zweite bool-Wert gibt an ob diese Zahl noch eine Primzahl sein könnte.

    for( unsigned ct = 0; ct < vec.size(); ++ct )
        vec[ct] = make_pair(ct + 2, true);

    for( unsigned ct = 0; ct < vec.size(); ++ct )
        if( vec[ct].second )
        {
            int value = vec[ct].first;

            for( unsigned multiple = value*value; multiple < vec.size() + 2; multiple += value )
                vec[multiple - 2].second = false;
        }

    /// Ausgabe:
    for( unsigned ct = 0; ct < vec.size(); ++ct )
        if( vec[ct].second )
            cout << vec[ct].first << ", ";
}