Advertisement
Shuva_Dev

Check substring or not

Nov 20th, 2022
801
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. string s1, s2;
  5.  
  6. int isSubString() {
  7.     int flag;
  8.     for(int i=0; i<s1.size(); i++) {
  9.         flag = 1;
  10.         for(int j=0; j<s2.size(); j++) {
  11.             if(s1[i+j] != s2[j]) {
  12.                 flag = 0;
  13.             }
  14.         }
  15.         if(flag) return 1;
  16.     }
  17. }
  18.  
  19. int main() {
  20.     cin >> s1 >> s2;
  21.  
  22.     cout << isSubString();
  23.  
  24.     return 0;
  25. }
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement