GastonFontenla

Untitled

Jun 5th, 2017
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     string input, buscar;
  8.     bool si=false;
  9.     int cant;
  10.  
  11.     cin>>input>>buscar;
  12.  
  13.     if(input.size()>buscar.size())
  14.         cant=input.size()-buscar.size()+1;
  15.     else
  16.         cant=buscar.size()-input.size()+1;
  17.  
  18.     for(int cont=0; cont<cant; cont++)
  19.     {
  20.         string comparar;
  21.         for(int cont2=cont, cont3=0; cont3<buscar.size(); cont2++, cont3++)
  22.         {
  23.             comparar += input[cont2];
  24.         }
  25.         if(si==false && comparar == buscar)
  26.             si=true;
  27.     }
  28.  
  29.     if(si==true) cout<<"SI";
  30.     else cout<<"NO";
  31.  
  32.     return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment