資源簡介
功能:利用哈希表實(shí)現(xiàn)英文翻譯功能
注:限輸入英文查找相應(yīng)漢語意思,秒出答案
有個別詞查不到的話,那是因?yàn)樵~庫不全
代碼片段和文件信息
//功能:利用哈希表實(shí)現(xiàn)英文翻譯功能
//注:限輸入英文查找相應(yīng)漢語意思,秒出答案
//有個別詞查不到的話,可能是因?yàn)?br/>//詞庫不是很全,還請見諒,僅供參考!
//by?blackstar
//2017.8.1
#include
#include
#include
#include
#include
#define?MaxSize?2048
using?namespace?std;
static?string?result;
bool?SearchWord(string?word);
struct?Word
{
string?word;??//單詞
string?line;???//所有
};
struct?Node????//hash表內(nèi)每個節(jié)點(diǎn)的數(shù)據(jù)結(jié)構(gòu)
{
Word?word;
Node?*next;
};
Node?*hashtable[MaxSize];
unsigned?int?ELFhash(string?str)//獲得鍵值
{
unsigned?int?hash?=?0;
unsigned?int?x?=?0;
for(int?i?=?0;i {
hash?=?(hash?<4)?+?str[i];
if?((x?=?hash?&?0xf0000000)?!=?0)
{
hash?^=?(x?>>?24);???//影響5-8位,雜糅一次???
hash?&=?~x;???//清空高四位???
}
}
return?(hash?&?0x7fffffff);
}
void?low
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????2994??2017-08-01?14:48??main.cpp
?????文件?????198313??2017-08-01?14:14??1.txt
-----------?---------??----------?-----??----
???????????????201307????????????????????2
- 上一篇:淘淘商城第三天筆記
- 下一篇:openla
yers3各種元素圖形繪制
評論
共有 條評論