/* Example of STL set - revision of set.cc * This version copies an array of strings into a set * compile: g++ -g copyToSet.cc * run: echo A C- E F | a.out * output: Y N Y N * The arguments from echo are each tested to see if they are in the set */ #include #include #include #include int main(int argc, char** argv) { std::string as[7] ={"A+","A","A-","B+","B","B-","E"}; std::set acceptable; std::copy( as, as+7, std::inserter(acceptable, acceptable.begin())); std::string next; while ( std::cin >> next ) std::cout << (acceptable.count( next ) ? "Y " : "N "); }