Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <bits/stdc++.h>
- #include <string.h>
- using namespace std;
- int contResp, contaux = 0;
- int teste(string string1, string stringaux,int aux1, int aux2, int cont){
- if(string1[aux1] == stringaux[aux2] && aux1< string1.length() && aux2<stringaux.length()){
- cont++;
- contaux = aux2+1;
- stringaux[aux2] = '^';
- return teste(string1, stringaux, aux1+1, aux2+1,cont);
- }else if(string1[aux1] != stringaux[aux2] && aux2<stringaux.length()-1){
- return teste(string1, stringaux, aux1, aux2+1, cont);
- }else if(aux2 == stringaux.length()-1 && stringaux[aux2]!= string1[aux1]){
- return teste(string1, stringaux, aux1+1,contaux, cont);
- }
- if(aux1 == string1.length()-1) {
- return cont;
- }
- }
- int main() {
- string string1, string2, stringaux;
- while(getline(cin,string1)){
- getline(cin,string2);
- stringaux = string2;
- int contaux;
- for (int i = 0; i<string1.length(); i++){
- stringaux = string2;
- contaux = teste(string1, stringaux, i, 0,0);
- if (contaux > contResp){
- contResp = contaux;
- }
- }
- cout << contResp << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement