• <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>
            posts - 3,  comments - 6,  trackbacks - 0
            #include <stdio.h>
            #include 
            <stdlib.h>
            #include 
            <string.h>

            #define SetSize 256 //字符集大小

            //說明:查找字符串中字符間不同的最大子串
            //參數:string 待搜索字符串
            //        rst 存放找到的最大子串
            //返回:找到最大子串長度
            int findMaxSubstring(const char *stringchar *rst){

                
            const char *= string;
                
            const char *substring = p;        //當前子串
                int length = 0;                //當前子串長度   
                const char *maxSubstring = substring;    //已經找到的最大子串
                int maxLength = 0;                //已經找到的最大子串長度

                
            // 遍歷字符串過程中,字符最后一次出現的位置
                const char* position[SetSize];
                memset(position, 
            0, SetSize * sizeof(char *));

                
            char ch;    //
                while ((ch = *p) != '\0')
                
            {          
                    
            if (position[ch] < substring){  //字符在當前子串首次出現   
                        length++;
                        
            if (length > maxLength){   
                            maxSubstring 
            = substring;
                            maxLength 
            = length;   
                        }
               
                    }
               
                    
            else {
                        substring 
            = position[ch] + 1;    //當前子串從該字符上次出現的位置后面開始
                        length = p - position[ch];
                    }


                    position[ch] 
            = p; // 保存字符的位置
                    p++;    
                }


                
            // 拷貝找到的最大子串
                strncpy(rst, maxSubstring, maxLength);
                rst[maxLength] 
            = '\0';
                
            return maxLength;   
            }
             



            據說這是微軟面試題。


            posted on 2010-08-29 17:30 custa 閱讀(645) 評論(0)  編輯 收藏 引用
            久久人人爽人人爽人人爽 | 亚洲中文字幕无码久久2020| 久久久久久亚洲Av无码精品专口 | 久久精品成人免费看| 亚洲色婷婷综合久久| 久久精品中文字幕一区| 五月丁香综合激情六月久久| 无码人妻久久久一区二区三区 | 伊人久久无码中文字幕| 久久亚洲熟女cc98cm| 久久亚洲国产成人影院| 影音先锋女人AV鲁色资源网久久| 性欧美大战久久久久久久久 | 精品久久久久久久中文字幕| 久久久久无码中| 亚洲精品99久久久久中文字幕| 伊人久久大香线蕉成人| 精品国产乱码久久久久久人妻| 亚洲香蕉网久久综合影视| 奇米综合四色77777久久| 九九99精品久久久久久| 久久中文字幕视频、最近更新| 久久精品国产亚洲AV蜜臀色欲| 欧美va久久久噜噜噜久久| 国产精品xxxx国产喷水亚洲国产精品无码久久一区 | 亚洲午夜精品久久久久久人妖| 国产国产成人久久精品| 国产精品99久久久精品无码| 精品无码久久久久国产| 久久99国产一区二区三区| 中文无码久久精品| 品成人欧美大片久久国产欧美| 一97日本道伊人久久综合影院| 久久综合给合久久国产免费| 亚洲国产精品久久| 大香伊人久久精品一区二区 | 久久久中文字幕日本| 亚洲欧美成人综合久久久| 国产一区二区精品久久凹凸| 久久久久久久亚洲Av无码| 午夜福利91久久福利|