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



  

相关话题

  c#入门书籍有推荐吗? 
  程序员反感(讨厌、不喜欢)什么? 
  GitHub 上可供新手阅读和玩耍的 Java 项目有哪些? 
  有哪些新手程序员不知道的小技巧? 
  如何看待2022年秋招Java后端开发岗一片红海? 
  如何评价CSDN? 
  写代码过程中最忌讳的是什么?总感觉最近太过于急于求成? 
  电脑点击“关机”后,电脑如何实现自动切断电源? 
  设计模式是不是有点太「玄」了? 
  如果中国一开始就禁止微软和英特尔AMD进入中国大陆地区,现在的中国大陆地区会出现哪些现象? 

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





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