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



  

相关话题

  作为程序员,是什么让你坚持不懈地学习?难道不累吗? 
  对于学习代码困难的人来说,应该如何学习代码比较合适? 
  好的或者成功的项目,代码就一定美吗? 
  如何系统地测试一门语言(规定工具链,运行时,以及运行环境)的性能? 
  Golang 为什么要发布一个新的字体? 
  参加ICPC国际编程竞赛的大学生到底有多厉害,在校生该如何准备? 
  计算机编程算是否是理科中比较偏文的科目? 
  让组员修改他自己写的恶臭代码,他回我「能跑就行」,该怎么办? 
  网络上有若干客户端向一台机器的某个端口一直不停发送UDP包 这台机器打开端口和不打开端口的区别在哪? 
  学习编程照着别人的代码敲进去有效率吗? 

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





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