#include #include #include // Run this by redirecting input to a file. // // programname < filename // int main() { string s; map m; // Get the words out of the input and // insert (s,0) into the map for each word s. while( cin >> s ) { m[s] = 0; } // Traverse the map in order, printing the key (a string) // and the value (an int) for each stop along the traversal. map::const_iterator it = m.begin(); while( it != m.end() ) { cout << (*it).first << ' ' << (*it).second << endl; it++; } // Here, you can determine whether a given key has been // inserted into the map. s = "moose"; it = m.find( s ); if( it != m.end() ) cout << (*it).first << ' ' << (*it).second << endl; else cout << "no moose" << endl; return 0; }