当前位置:首页 > 技术问答集
firefox

我新建了个网易邮箱,大家可以到网易网盘下载电子图书,也请上传啊!大家请互相交流信息!

 所属目录:asp.net   |   类型:技术问答   |   时间:2007-05-12
 问题:

如:串a:abes   串b:befs  
  则相同的子串为:be,s  
  各位大哥有什么好的方法,能否给个源程序参考一下。  
 

· 网友精彩回答:

发表者:du51(郁郁思扬)

#include<stdio.h>  
  #include<stdlib.h>  
  #include<string.h>  
  int   noname(char   *p,char   *str)  
  {  
          char   *q=p+1,e=*q;  
          *q=0;  
          while(strstr(str,p))  
  {  
  if(!e)return   q-p;  
  *q=e;  
  q++;  
  e=*q;  
  *q=0;  
  }  
          *q=e;  
          return   q-p-1;  
  }    
  void   mystr(char   *str1,char   *str2)  
  {  
          char   *p=str1,*q,e;  
          int   i,j=0,k=0;  
          if(!str1||!str2)return;  
          while(*p)  
          {  
                  if(i=noname(p,str2))  
                  {  
                          q=p+i,e=*q,*q=0;  
        if(i+k>j)  
        {  
  printf("%s\n",p);  
  k=0;  
  j=i;  
   
        }  
                          *q=e,k++;  
                  }  
                  else   j=0,k=0;  
                  p++;  
          }      
  }      
  int   main()  
  {  
          char   str1[256]="abcwwbcabes",str2[256]="abcabefsww";  
          mystr(str1,str2);  
          system("pause");  
          return   0;  
  }

.
处理 SSI 文件时出错
© 2006-2008 All Rights Reserved