1 #include<stdio.h>
   2 #include<string.h>
   3 typedef struct 
   4 {  char ch[50];
   5    int len;
   6 }SqString;
   7 int creat_string(SqString s1,SqString s2,SqString s);
   8 int check(int a[50][50]);
   9 
  10 
  11 void main()
  12 {  int i=0;
  13    SqString s,s1,s2;
  14    scanf("%s",&s1.ch);
  15    s1.len=strlen(s1.ch); 
  16    scanf("%s",&s2.ch);
  17    s2.len=strlen(s2.ch);
  18    for(i=0;i<10;i++){
  19 
  20    s.ch[i]='*';
  21         s.len++;
  22    }
  23    creat_string(s1,s2,s);
  24    return ;
  25 }
  26 int creat_string(SqString s1,SqString s2,SqString &s)
  27 {  int i,j,k,m,n,t=0;
  28    int a[50][50];
  29    int b[50][50];
  30    for(i=0;i<50;i++)
  31            for(j=0;j<50;j++)
  32            a[i][j]=b[i][j]=0;
  33    for(i=0;i<s1.len;i++)
  34            for(j=0;j<s2.len;j++)
  35                    if(s1.ch[i]==s2.ch[j])
  36                            a[i][j]=1;
  37    k=1;
  38    while(check(a))
  39    {
  40           for(i=0;i<s1.len;i++)
  41         for(j=0;j<s2.len;j++)
  42                 {
  43                b[i][j]=a[i][j];
  44                 }
  45           for(m=0;m<s1.len;m++)
  46           {   while(i<s1.len&&j<s2.len)
  47           {     if(a[i][j]==1&&a[i+k][j+k]==0)
  48           {         a[i][j]=0;
  49                     i=i+k+1;
  50                                 j=j+k+1;
  51           }
  52                 else
  53                         {i++;
  54                          j++;
  55                         }
  56           }
  57           }
  58           for(n=0;n<s2.len;n++)
  59           {   while(i<s1.len&&j<s2.len)
  60           {     if(a[i][j]==1&&a[i+k][j+k]==0)
  61           {         a[i][j]=0;
  62                     i=i+k+1;
  63                                 j=j+k+1;
  64           }
  65                 else
  66                         {i++;
  67                          j++;
  68                         }
  69           }
  70           }
  71           k++;
  72         }
  73         while(i<s1.len&&j<s2.len)
  74                         if(b[i][j]==1)
  75                                 for(;t<k;t++)
  76                                 { s.ch[t]=s1.ch[i];
  77                                   i++;
  78                                 }
  79         printf("%s",s.ch);
  80         return 1;
  81 }
  82 int check(int a[50][50])
  83 { int i,j;
  84   for(i=0;i<50;i++)
  85         for(j=0;j<50;j++)
  86                         if(a[i][j]!=0)
  87                                 return 1;
  88   return 0;
  89 }
  90 
  91 ...