#include #include #include #include using namespace std; string convert(string s) { string result = ""; for (int i = 0; i < s.length(); i += 1) { char c = s[i]; if (islower(c)) result += c; else if (isupper(c)) result += (char)tolower(c); else if (isdigit(c)) result += c; } return result; } int main() { ifstream in("/home/www/text/barrie/peterpan"); if (in.fail()) { cout << "Can't read home/www/text/barrie/peterpan\n"; exit(1); } const int max = 47800; string words[max]; int counts[max]; int number = 0; for (int i = 0; i < max; i += 1) { words[i] = ""; counts[i] = 0; } while (true) { string word; in >> word; if (in.fail()) break; word = convert(word); if (word == "") continue; bool matched = false; for (int i = 0; i < number; i += 1) if (words[i] == word) { counts[i] += 1; matched = true; break; } if (! matched) { if (number >= max) { cout << "The arrays are not big enough\n"; exit(1); } words[number] = word; counts[number] = 1; number += 1; } } in.close(); for (int i = 0; i < number; i += 1) cout << words[i] << " " << counts[i] << "\n"; }