Advertisement
mateuspl

CodeForces: 625B

Feb 19th, 2016
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.34 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     string str, sub;
  8.     cin >> str >> sub;
  9.  
  10.     int iStr(0), iSub(0), count(0);
  11.  
  12.     for (; iStr < str.length(); iStr++)
  13.     {
  14.         if (str[iStr] == sub[iSub])
  15.         {
  16.             if (++iSub == sub.length())
  17.             {
  18.                 iSub = 0;
  19.                 count++;
  20.             }
  21.         }
  22.         else iSub = 0;
  23.     }
  24.  
  25.     cout << count;
  26.  
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement