• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            gzwzm06

              C++博客 :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
              1 隨筆 :: 52 文章 :: 17 評論 :: 0 Trackbacks
            #include <stdio.h>
            #include 
            <cstring>

            const int MAXN = 131101 ;
            const int SIZE = 100001 ;
            struct HashItem
            {
                
            char matchStr[12] ;
                
            char memStr[12] ;
                HashItem 
            *next ;
                HashItem() 
            {
                    next 
            = NULL ;
                }

            }
            hash[MAXN] , g_Temp[SIZE] ;

            int g_Pos ;

            int RKHash( char *str )
            {
                unsigned 
            long hash = 0 ;

                
            while ( *str )
                
            {
                    hash 
            = (hash * 26+ (*str - 'a') ;
                    str
            ++ ;
                }


                
            return (hash % MAXN) ;
            }


            void Insert( char *str , char *mstr )
            {
                
            int key = RKHash( str ) ;

                HashItem 
            *= &g_Temp[g_Pos++] ;
                strcpy( p
            ->memStr, mstr ) ;
                strcpy( p
            ->matchStr, str ) ;
                p
            ->next = NULL ;
                p
            ->next = hash[key].next ;
                hash[key].next 
            = p ;
                
            }


            int Find( char *str , char *mstr )
            {
                
            int key = RKHash( str ) ;
                
            int pos = 0 ;

                HashItem 
            *= hash[key].next ;

                
            while ( p )
                
            {
                    
            if ( strcmp( p->matchStr, str ) == 0 )
                    
            {
                        pos 
            = 1 ;
                        strcpy( mstr, p
            ->memStr ) ;
                        
            break ;
                    }

                    p 
            = p->next ;
                }

                
                
            return pos ;
            }


            void Init()
            {
                g_Pos 
            = 0 ;

                
            for ( int i = 0 ; i < MAXN ; ++i )
                    hash[i].next 
            = NULL ;
            }


            int main()
            {
                
            char str[2][12] , tmpStr[50] ;
                
            int x ;

                Init() ;

                
            while ( gets(tmpStr) && tmpStr[0] )
                
            {
                    sscanf( tmpStr, 
            "%s%s", str[0], str[1] ) ;

                    Insert( str[
            1], str[0] ) ;
                }


                
            while ( scanf("%s"&str[0]) != EOF )
                
            {
                    x 
            = Find( str[0] , str[1] ) ;

                    
            if ( x == 1 )
                    
            {
                        printf(
            "%s\n", str[1]) ;
                    }

                    
            else {
                        printf(
            "eh\n") ;
                    }

                }


                
            return 0 ;
            }
            posted on 2008-11-09 23:15 閱讀(426) 評論(0)  編輯 收藏 引用 所屬分類: Hash應用
            久久久噜噜噜久久熟女AA片| 久久久老熟女一区二区三区| 精品久久久久一区二区三区 | 精品久久久久久国产| 无遮挡粉嫩小泬久久久久久久| 久久精品国产亚洲AV无码偷窥 | 久久综合伊人77777麻豆| 蜜桃麻豆WWW久久囤产精品| 国产精品无码久久综合| 国产精品VIDEOSSEX久久发布| 久久久久久噜噜精品免费直播| 日韩av无码久久精品免费| 久久成人永久免费播放| 久久综合给久久狠狠97色 | 久久久青草青青国产亚洲免观| 精品国产乱码久久久久久人妻| 久久综合九色综合久99| 久久久久久亚洲AV无码专区| 久久综合一区二区无码| 91久久精品无码一区二区毛片| 久久精品国产亚洲AV忘忧草18| 伊人久久精品线影院| 久久99精品久久久久子伦| 久久精品免费全国观看国产| 久久久久一级精品亚洲国产成人综合AV区| 久久人人爽人人爽人人片AV不 | 久久只有这精品99| 国产精品99久久不卡| 色综合久久88色综合天天 | 久久久久国色AV免费看图片| 精品无码久久久久久尤物| 久久久久亚洲AV成人网人人网站 | 国产V综合V亚洲欧美久久| 久久人人添人人爽添人人片牛牛| 久久久久人妻一区精品| 国产精品亚洲综合专区片高清久久久 | av色综合久久天堂av色综合在| 久久亚洲2019中文字幕| 国内精品久久久久国产盗摄| 亚洲成色999久久网站| 色综合久久久久网|