#include #include #include #include #include // for exit using namespace std; ostream& operator <<(ostream& out,const pair& p) { out << p.second << "\t" << p.first; return out; } struct stringhash { size_t operator() (const string& s) const { return hash()(s.c_str()); } }; int main(int argc, char *argv[]) { string filename,w; if (argc == 1) { cerr << "usage: " << argv[0] << " filename" << endl; exit(1); } filename = argv[1]; ifstream input(filename.c_str()); hash_map > m; while (input >> w) { m[w]++; } copy(m.begin(),m.end(), ostream_iterator >(cout,"\n")); return 0; }