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



  

相关话题

  程序员有哪些借口可以让自己写出低质量的代码? 
  为什么GCC的版本号增速比以前快这么多? 
  既然有 memcpy_s 这种安全实现,为啥不禁用危险的 memcpy 或者更新 memcpy 源码? 
  程序员用机械键盘是为了识别敲击声还是为了宏编程所带来的方便? 
  你是如何自学 Python 的? 
  如果要给编程语言加上一种可用于计量运算的基本数字类型,你觉得该怎么设计这种计量类型,以及修改语言本身? 
  请问这段代码是什么意思,据说能让人月入过w? 
  如何看待没有学历的程序员? 
  这种代码命名规范,到底好不好? 
  怎么编程实现if,不使用if关键字? 

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





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