Advertisement
Josif_tepe

Untitled

Dec 24th, 2023
756
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.61 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.    
  7.     string text;
  8.     string pattern;
  9.     cin >> text;
  10.     cin >> pattern;
  11.    
  12.     for(int i = 0; i < (int) text.size(); i++) {
  13.         if(text[i] == pattern[0]) {
  14.             bool ok = true;
  15.             for(int j = 0; j < (int) pattern.size(); j++) {
  16.                 if(i + j >= (int) text.size() or pattern[j] != text[i + j]) {
  17.                     ok = false;
  18.                     break;
  19.                 }
  20.             }
  21.             if(ok) {
  22.                 cout << "DA postoi" << endl;
  23.             }
  24.         }
  25.     }
  26.  
  27.    return 0;
  28. }
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement