// File: set2.cpp // // Simple use of STL set container class // #include #include #include using namespace std ; const unsigned long int seed = 38913154 ; //const int reps = 10000 ; // ten thousand //const int reps = 20000 ; // twenty thousand //const int reps = 200000 ; // two *hundred* thousand const int reps = 400000 ; // four *hundred* thousand int main() { set S ; int x, found = 0 ; srandom(seed) ; for (int i = 0 ; i < reps ; i++) { S.insert(random()) ; } for (int i = 0 ; i < reps ; i++) { x = random() ; if (S.find(x) != S.end()) found++ ; } cout << "Number of random numbers found: " << found << "\n" ; }