• <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 閱讀(638) 評論(0)  編輯 收藏 引用
            久久嫩草影院免费看夜色| 久久99国产精一区二区三区| 免费精品国产日韩热久久| 99久久99久久久精品齐齐| 国产成人久久激情91| 一本一道久久精品综合| 久久99久久无码毛片一区二区 | 久久久久高潮综合影院| 人妻无码αv中文字幕久久琪琪布 人妻无码久久一区二区三区免费 人妻无码中文久久久久专区 | 99热热久久这里只有精品68| 久久精品人成免费| 秋霞久久国产精品电影院| 欧美精品福利视频一区二区三区久久久精品 | 欧美一区二区精品久久| 久久精品国产福利国产琪琪| 合区精品久久久中文字幕一区| 亚洲精品国产第一综合99久久| 久久久久高潮毛片免费全部播放| 久久国产亚洲精品麻豆| 久久亚洲日韩精品一区二区三区| 精品综合久久久久久97超人 | 国产精品久久久久a影院| 精品久久久久中文字| 国产精品久久午夜夜伦鲁鲁| 一本色道久久88精品综合| 久久影视国产亚洲| 伊人 久久 精品| 久久久久成人精品无码中文字幕| 久久无码高潮喷水| …久久精品99久久香蕉国产| 国产A三级久久精品| 97久久精品人妻人人搡人人玩| 久久天堂AV综合合色蜜桃网 | 久久精品国产秦先生| 久久se精品一区二区影院| 亚洲午夜福利精品久久| 色综合久久中文字幕无码| 国产91久久综合| 五月丁香综合激情六月久久| 久久久精品一区二区三区| 久久久久亚洲精品无码网址 |