Advertisement
Guest User

Untitled

a guest
Mar 1st, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. #include<iostream>
  2. #include<conio.h>
  3. #include<string.h>
  4.  
  5. using namespace std;
  6.  
  7.  
  8. int hashFunc(char* str)
  9. {
  10. int sum = 0;
  11. for(int i = 0;i<strlen(str);i++)
  12. {
  13. sum = sum + (int)str[i];
  14. }
  15.  
  16. return sum % 73;
  17. }
  18.  
  19.  
  20. int main()
  21. {
  22.  
  23.  
  24. cout <<"hashFunc("<<"slon) = "<< hashFunc("slon")<<endl;
  25. cout <<"hashFunc("<<"olsn) = "<< hashFunc("olsn")<<endl;
  26. cout <<"hashFunc("<<"cat) = "<< hashFunc("cat")<<endl;
  27. cout <<"hashFunc("<<"dog) = "<< hashFunc("dog")<<endl;
  28.  
  29. getch();
  30. return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement