fork download
  1. #include<string>
  2. #include<iostream>
  3. unsigned long long hash( std::string str )
  4. {
  5. unsigned long long _hash = 5381;
  6. for( unsigned char znak: str )
  7. _hash =(( _hash << 5 ) + _hash ) + znak; /* hash * 33 + c */
  8.  
  9. return _hash;
  10. }
  11.  
  12. int main()
  13. {
  14. std::string s = "witam";
  15. std::cout << hash( s );
  16. }
Success #stdin #stdout 0s 16064KB
stdin
Standard input is empty
stdout
210732577351