比如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]=’