#include #include #include #include #include #include using namespace std; int main() { char punct[6] = {'.', ',', '?', '!', ':', ';'}; set punctuation(punct, punct + 6); ifstream in("prose.txt"); if (!in) { cerr << "File not found\n"; exit(1); } map wordCount; string s; while (in >> s) { int n = s.size(); if (punctuation.count(s[n - 1])) s.erase(n - 1, n); ++wordCount[s]; } ofstream out("freq_map.txt"); map::const_iterator it = wordCount.begin(); for (it; it != wordCount.end(); ++it) out << setw(20) << left << it->first << setw(4) << right << it->second << endl; return 0; }