// File: list2.cpp // // Simple use of STL list 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() { list L ; list::iterator it ; int x, found = 0 ; srandom(seed) ; for (int i = 0 ; i < reps ; i++) { L.push_back(random()) ; } for (int i = 0 ; i < reps ; i++) { x = random() ; for(it = L.begin() ; it != L.end() ; it++) { if (x == *it) { found++ ; break ; } } } cout << "Number of random numbers found: " << found << "\n" ; }