Advertisement
Guest User

Untitled

a guest
Apr 16th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. int tabelDispersie[N] = { NULL };
  2. int altTabel[] = { 7, 13, 44, 18, 20, 4, 2, 99, 100, 5, 777 };
  3.  
  4. int factorDeUmplere = (95 * N) / 100;
  5. //for (int i = 0; i < sizeof(altTabel) / sizeof(int); i++) {
  6. for (int i = 0; i < factorDeUmplere; i++){
  7.  
  8. if (!(hashTableInsert(altTabel[i], tabelDispersie)))
  9. break;
  10. }
  11.  
  12. printf("Tabel initial:");
  13. for (int i = 0; i < sizeof(altTabel) / sizeof(int); i++) {
  14.  
  15. printf("%d ", altTabel[i]);
  16. }
  17. printf("\n");
  18.  
  19. printf("Afisare tabela de dispersie:\n");
  20. for (int i = 0; i < N; i++) {
  21. printf("Pe pozitia %d avem: %d \n", i, tabelDispersie[i]);
  22. } //0: 20; 1: 100; 2: 2; 3: 13; 4: 44; 5: 4; 6: 5; 7: 7; 8: 18; 9: 99
  23.  
  24. int nrS = 0;
  25. int nrMaxS = 1;
  26. int index = hashKeySearch(altTabel[7], tabelDispersie, &nrS, &nrMaxS);
  27. if (index)
  28. printf("Cheia %d a fost gasita la indexul: %d!\n", altTabel[7], index);
  29. else
  30. printf("Cheia nu a fost gasita in tabela!\n");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement