阅读背景:

字符串hash kmp算法

来源:互联网 
#include <stdio.h>


unsigned int BKDRHash(char* str){//字符串hash
	unsigned int seed = 131;// 31 131 1313 13131 131313 etc..
	unsigned int hash = 0;
	while (*str){
		hash = hash * seed + (*str++);
	}
	return hash&0x7fffffff;
}

int main(){
	unsigned int res = BKDRHash("abcdef");
	printf("%d\n",res);
	return 0;
}#include <stdio.h>


unsigned int BKDRHash(char



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: