#include #include const int maxx = 10000; int thing(string s) { int h = 278361; int len = s.length(); for (int i = 0; i < len; i += 1) h = h * 69 + s[i]; if (h < 0) h = -h; return h % maxx; } void main() { string words[maxx]; int news = 0, olds = 0, clashes = 0; cout << "Type some strings.\n"; while (true) { string s; cin >> s; if (cin.eof()) break; int x = thing(s); if (words[x] == "") { news += 1; words[x] = s; } else if (words[x] == s) olds += 1; else clashes += 1; } cout << "all done.\n"; cout << "old: " << olds << "\n"; cout << "new: " << news << "\n"; cout << "clash: " << clashes << "\n"; }