Advertisement
nontawat1996

1019 2

Sep 22nd, 2011
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.93 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. int main()
  5. {
  6.     int start,end,max=0,sum=0,i,j,di=0,tod1;
  7.     char dna1[202]= {'\0'},dna2[202]= {'\0'};
  8.     scanf("%s%s",dna1,dna2);
  9.     for(i=0; i<strlen(dna1); i++)
  10.     {
  11.         di=i;
  12.         for(j=0; j<strlen(dna2); j++)
  13.         {
  14.             if(dna1[i]==dna2[j])
  15.             {
  16.                 if(sum==0) tod1=j;
  17.                 sum++;
  18.                 if(sum>max)
  19.                 {
  20.                     start=tod1;
  21.                     end=j;
  22.                     max=sum;
  23.                 }
  24.                 i++;
  25.                 if(i==strlen(dna1))
  26.                 {
  27.                     sum=0;
  28.                     break;
  29.                 }
  30.             }
  31.             else
  32.             {
  33.                 i=di;
  34.                 if(sum==1) j--;
  35.                 sum=0;
  36.             }
  37.         }
  38.     }
  39.     for(i=start; i<=end; i++) printf("%c",dna2[i]);
  40.     return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement