Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
那位牛头帮忙看看这个代码哪里错了啊,ORZ#include <stdio.h> #include <string.h> int hash[160001]; char engl[150001][14]; int hashFunction(char* str) { unsigned long h = 0, g; int nKeyLength=strlen(str); char *arEnd=str+nKeyLength; while (str<arEnd) { h = (h << 4) + *str++; if ((g = (h & 0xF0000000))) { h = h ^ (g >> 24); h = h ^ g; } } h=h%149999; return h; } int main() { memset(hash,0,sizeof(hash)); char fo[14],en[14],test[14],buff[50]; int j=1; while (gets (buff) && strcmp (buff, "") != 0) { sscanf(buff,"%s%s",en,fo); int index=hashFunction(fo); int k=0; while(engl[index][0]!='\0') { index++; k++; } hash[index-k]=k; strcpy(engl[index],en); } while(gets(test)) { int i=hashFunction(test); if(engl[i+hash[i]][0]!='\0') { printf("%s\n",engl[i+hash[i]]); } else printf("eh\n"); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator