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



  

相关话题

  为什么编程语言对异步编程都是很晚近才开始支持的? 
  网上常能见到的一段 JS 随机数生成算法如下,为什么用 9301, 49297, 233280 这三个数字做基数? 
  闭源软件有类似于开源软件那种许可证吗? 
  不太喜欢计算机,不喜欢编程,但是学了一段时间老师觉得我还可以,还建议学吗? 
  如何轻松阅读 GitHub 上的项目源码 ? 
  为什么 Windows 系统 Program Files 这个经常用来装软件的目录,名称中有个空格? 
  中文表达比英文简洁,中文编程能否做到比英文编程更高效? 
  计算机编程算是否是理科中比较偏文的科目? 
  编程新手如何提高编程能力? 
  不同编程语言的转义字符可以通用吗? 

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





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