百科问答小站 logo
百科问答小站 font logo



请问这段代码是什么意思,据说能让人月入过w? 第1页

  

user avatar   lu-mi-ya-56 网友的相关建议: 
      

这是DJB2 hash算法,用途将一个字符串映射为一个整数,由Daniel J. Bernstein在1991年发明……

       hash(unsigned char *str) {     unsigned long hash = 5381;     int c;      while (c = *str++)         hash = ((hash << 5) + hash) + c; /* hash * 33 + c */      return hash; }     

介绍可以看这里

Written by Daniel J. Bernstein (also known as djb), this simple hash function dates back to 1991.
Hash functions have wide applications in computer science and in cryptography. They are used to map a potentially large amount of data to a number that represents it.
For example, the hash function from this code snippet maps Hello to 210676686969, but Hello! to 6952330670010. Despite the fact there’s only one character different (the exclamation mark), the number returned is completely different.



  

相关话题

  计算机领域有哪些经典的典故或笑话? 
  为什么大多数编译厂商不把 bool 类型实现为 1 bit 而是 8 bit 或者32 bit? 
  python如何将变量名转化为同名字符串? 
  给你们看一下上海的政策,想请教一下编程高手,这IF语句,是无限循环还是死循环,可以跳出吗? 
  C#中字符串可以使用可变大小的内存,为什么数字不能? 
  如何看待网传美团王兴怼宝马 X5 研发技术和特斯拉比差距大?代码行多少能代表研发水平高低吗? 
  为什么信息竞赛题题解较多使用缩写、魔数、宏定义? 
  大家是怎么念 null 的? 
  手机游戏《明日方舟》里的阿米娅到底是兔子还是驴? 
  计算机系应届生参加校招屡屡碰壁,请问像我这样条件的应届生算什么水平? 

前一个讨论
为什么现在的男孩子谈恋爱都喜欢白嫖?
下一个讨论
有律师执照的律师,真的可以随时说出某个人违反了什么法、第几条吗?





© 2025-05-29 - tinynew.org. All Rights Reserved.
© 2025-05-29 - tinynew.org. 保留所有权利