<pre id="bbfd9"><del id="bbfd9"><dfn id="bbfd9"></dfn></del></pre>

          <ruby id="bbfd9"></ruby><p id="bbfd9"><mark id="bbfd9"></mark></p>

          <p id="bbfd9"></p>

          <p id="bbfd9"><cite id="bbfd9"></cite></p>

            <th id="bbfd9"><form id="bbfd9"><dl id="bbfd9"></dl></form></th>

            <p id="bbfd9"><cite id="bbfd9"></cite></p><p id="bbfd9"></p>
            <p id="bbfd9"><cite id="bbfd9"><progress id="bbfd9"></progress></cite></p>

            雅虎筆試題(字符串操作)

            時間:2020-11-21 18:18:29 筆試題目 我要投稿

            雅虎筆試題(字符串操作)

              給定字符串A和B,輸出A和B中的'最大公共子串。

            雅虎筆試題(字符串操作)

              比如A=”aocdfe” B=”pmcdfa” 則輸出”cdf”

              */

              //Author: azhen

              #include

              #include

              #include

              char *commanstring(char shortstring[], char longstring[])

              {

              int i, j;

              char *substring=malloc(256);

              if(strstr(longstring, shortstring)!=NULL) //如果……,那么返回shortstring

              return shortstring;

              for(i=strlen(shortstring)-1;i>0; i–) //否則,開始循環計算

              {

              for(j=0; j<=strlen(shortstring)-i; j++){

              memcpy(substring, &shortstring[j], i);

              substring[i]=’\0′;

              if(strstr(longstring, substring)!=NULL)

              return substring;

              }

              }

              return NULL;

              }

              main()

              {

              char *str1=malloc(256);

              char *str2=malloc(256);

              char *comman=NULL;

              gets(str1);

              gets(str2);

              if(strlen(str1)>strlen(str2)) //將短的字符串放前面

              comman=commanstring(str2, str1);

              else

              comman=commanstring(str1, str2);

              printf(“the longest comman string is: %s\n”, comman);

              }

            【雅虎筆試題(字符串操作)】相關文章:

            《PHP字符串操作》收集整理11-23

            linux shell編程變臉賦值和字符串操作10-05

            JavaScript中常見的字符串操作函數及用法11-14

            華為2017筆試題08-16

            360筆試題目07-11

            php開發中常用的操作字符串的函數說明11-15

            華為2017筆試試題08-10

            Linux操作試題及答案09-11

            excel操作試題及答案10-05

                    <pre id="bbfd9"><del id="bbfd9"><dfn id="bbfd9"></dfn></del></pre>

                    <ruby id="bbfd9"></ruby><p id="bbfd9"><mark id="bbfd9"></mark></p>

                    <p id="bbfd9"></p>

                    <p id="bbfd9"><cite id="bbfd9"></cite></p>

                      <th id="bbfd9"><form id="bbfd9"><dl id="bbfd9"></dl></form></th>

                      <p id="bbfd9"><cite id="bbfd9"></cite></p><p id="bbfd9"></p>
                      <p id="bbfd9"><cite id="bbfd9"><progress id="bbfd9"></progress></cite></p>
                      飘沙影院