用c语言写一个哈希算法

我不是很了解C语言,但是我可以尝试给出一个哈希算法的实现: unsigned int hash(char *str) { unsigned int hash = 5381; int c;

while (c = *str++)
    hash = ((hash << 5) + hash) + c; /* hash * 33 + c */

return hash;

}

猜你喜欢

转载自blog.csdn.net/weixin_42577735/article/details/129515599
今日推荐