• <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 閱讀(647) 評論(0)  編輯 收藏 引用
            国产精品美女久久久久AV福利| 久久精品国产亚洲AV香蕉| 久久精品国产亚洲一区二区| 亚洲午夜无码久久久久| 久久精品国产免费观看三人同眠| 无码日韩人妻精品久久蜜桃| 激情伊人五月天久久综合| 色综合久久天天综合| 久久青青草原亚洲av无码| 无码人妻久久一区二区三区免费 | 一级做a爰片久久毛片看看| 一97日本道伊人久久综合影院| 亚洲中文久久精品无码ww16| 精品国产乱码久久久久久1区2区 | 久久久精品人妻一区二区三区蜜桃 | 久久久久久久综合狠狠综合| 亚洲中文久久精品无码ww16| 久久九九青青国产精品| 久久久亚洲裙底偷窥综合| 国产精品久久久久久影院| 久久婷婷色综合一区二区| 久久九九全国免费| 久久亚洲国产成人精品性色| 久久亚洲精品无码观看不卡| 久久久久无码精品国产| 国产香蕉久久精品综合网| 热99re久久国超精品首页| 久久久无码精品亚洲日韩按摩| 色诱久久av| 国产高潮久久免费观看| 国产成人久久AV免费| 一级做a爰片久久毛片看看| 久久人人爽人人爽AV片| 一本伊大人香蕉久久网手机| 久久精品国产亚洲AV麻豆网站| 国产精品美女久久福利网站| 人人狠狠综合久久亚洲| 91精品日韩人妻无码久久不卡| 99久久精品国内| 久久精品国产亚洲av影院| 久久人与动人物a级毛片|