| 5 | return key % 13; |
| 6 | } |
| 7 | int main() |
| 8 | { |
| 9 | int a[] = {26, 28, 31, 34, 35, 25, 31, 31, 31, 25}; |
| 10 | int h[13]; |
| 11 | int n = 13; |
| 12 | for (int i = 0; i < 13; i++) |
| 13 | h[i] = -999; |
| 14 | for (int i = 0; i < 10; i++) |
| 15 | { |
| 16 | if (h[hashfunction(a[i])] != -999) |
| 17 | { |
| 18 | int j = 1; |
| 19 | int pcount = 1; |
| 20 | int k; |
| 21 | k = hashfunction(a[i]); |
| 22 | while (pcount < n / 2 && h[(k + j) % 13] != -999) |
| 23 | { |
| 24 | k = (k + j) % 13; |
| 25 | cout << a[i] << "->" << k << " "; |
| 26 | j = j + 2; |
| 27 | pcount++; |
| 28 | } |
| 29 | cout << endl; |
| 30 | if (h[(k + j) % 13] == -999) |
| 31 | h[(k + j) % 13] = a[i]; |
| 32 | } |
| 33 | else |
| 34 | h[hashfunction(a[i])] = a[i]; |
| 35 | } |
| 36 | for (int i = 0; i < 13; i++) |
| 37 | cout << h[i] << " "; |
| 38 | } |
nothing calls this directly
no test coverage detected