Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <conio.h>
  4. using namespace std;
  5.  
  6. int main() {
  7. int n = 29;
  8. vector<int *> buckets(n, NULL);
  9.  
  10. auto hp = [](int k) { return k % 29; };
  11. int c1 = 0;
  12. int c2 = 1;
  13. auto hp2 = [=](int k)
  14. {
  15. return 1 + ((k % (n - 1)) % n);
  16. };
  17. auto h = [=](int k, int i)
  18. {
  19. return (hp(k) + c1*i + c2*i*i) % n;
  20. };
  21. auto doble = [=](int k, int i)
  22. {/*hp2(k) = 1 + (k % (n - 1));*/
  23. return (hp(k) + i*hp2(k));
  24. };
  25. vector<int> nums = { 6, 34, 67, 92, 96, 8, 53, 5, 3, 2 };
  26. for (auto k : nums) {
  27. for (int i = 0; i < n; ++i) {
  28. auto index = doble(k, i);
  29. cout << index << " ";
  30. if (buckets[index] == nullptr) {
  31. buckets[index] = new int;
  32. (*buckets[index]) = k;
  33. break;
  34. }
  35. }
  36. cout << endl;
  37. }
  38. /*system("pause>0");*/
  39. getch();
  40. return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement