Listing 2: Demonstrates application of an std::set

#include<stdlib.h>
#include<time.h>
#include<set>
#include<algorithm>
#include<iostream>

std::set<int> setRandomInts;
srand( (unsigned)time( NULL ) );
for(int i=0; i<50; ++i)
    setRandomInts.insert(abs(rand())%42);
  
if( setRandomInts.end() != setRandomInts.find(13) )
    std::cout << 13 << " found\n";
else
    std::cout << 13 << " not found\n";

— End of Listing —