Advertisement
Guest User

Untitled

a guest
Dec 20th, 2013
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. #include <cmath>
  2. #include <cstdio>
  3. #include <vector>
  4. #include<string>
  5. #include <iostream>
  6. #include <algorithm>
  7. using namespace std;
  8.  
  9. void max(string a,string b,int n)
  10. {
  11.     int count=0,x=-1,prev=0,i,j,k;
  12.     for(i=0;i<n;i++)
  13.     {
  14.         x=-1;
  15.         for(j=i;j<n;j++)
  16.         {
  17.             for(k=x+1;k<n;k++)
  18.             {
  19.                 if(a[j]==b[k])
  20.                 {
  21.                     count++;
  22.                     x=k;
  23.                     break;
  24.                 }
  25.             }
  26.         }
  27.         if(prev<count)
  28.         {
  29.             prev=count;
  30.         }
  31.         count=0;        
  32.     }
  33.     cout<<prev;
  34. }
  35.  
  36. int main() {
  37.     string a,b;
  38.     int n;
  39.     cin>>a;
  40.     cin>>b;
  41.     n=a.length();
  42.     max(a,b,n);
  43.     return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement