Advertisement

单词拼写检查

阅读量:

改写后的内容

复制代码
    //单词拼写检查
    #include<iostream>
    #include<cstdio>
    #include<cstring>
    #define fo(i,j,k) for(i=j;i<=k;i++)
    using namespace std;
    const int maxn=19997;
    int tot;
    string h[maxn+1];
    int hash(string x)
    {
    int t,l,m;
    l=x.size();
    m=l/2;
    t=(x[0]-'a')*10000+(x[m]-'a')*100+(x[l-1]-'a');
    return t%maxn;
    }
    void insert(string word)
    {
    int t=hash(word);
    while(h[t]!="" && h[t]!=word)  //若t未被访问过 
    {
        t++;
        if(t==maxn)
          t=0;
    }
    h[t]=word;
    }
    void find(string word)
    {
    int t=hash(wor

全部评论 (0)

还没有任何评论哟~