百科问答小站 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.



  

相关话题

  如何用一句(段)代码表现孤独? 
  用 vim 能写大型程序吗? 
  计算机系应届生参加校招屡屡碰壁,请问像我这样条件的应届生算什么水平? 
  在宿舍写代码总被一个室友认为在装逼,该怎么办? 
  可以在非中文的网站使用中文吗? 
  各种编程语言的成功/代表产品有哪些? 
  多用组合少用继承中,接口继承算不算一种组合? 
  忽然发现自己敲键盘的指法很不标准,我觉得已经对 coding 效率产生影响,怎么办? 
  想在业余时间刷leetcode,配合什么书籍/课程/视频网站一起刷leetcode的效率最高? 
  面试 C# 被人问你是如何优化你的代码的,该从哪些方面进行回答? 

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





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