#include #include #include const int init = 21512712, mult = 96169, emergency = 82631927; const int tabsize = 100000; int hash(string s) { int v = init; for (int i=0; i> s; if (fin.fail()) { cout << i << " read OK\n"; break; } words += 1; int h = hash(s); // open hashing with linear probing while (table[h] != "" && table[h] != s) { h += 1; skips += 1; if (h == tabsize) h = 0; } table[h] = s; } cout << words << " words, " << skips << " skips, " << (double)skips/words << "\n"; fin.close(); }