Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- #include<string>
- using namespace std;
- int main()
- {
- string S, P, M;
- bool matching;
- cin >> S >> P;
- // case: S.length() >= P.length()
- for (int i = 0; i <= S.length() - P.length(); i++)
- {
- matching = true;
- for (int k = 0; k < P.length(); k++)
- {
- if(S[i+k] != P[k] && P[k] != '*')
- {
- matching = false;
- break;
- }
- }
- if(matching)
- {
- M.append(to_string(i));
- }
- }
- for(int i = 0; i < M.length(); i++)
- {
- if( i == 0) cout << "M=[";
- cout << M[i] ;
- if( i != M.length() - 1) cout << ',';
- if( i == M.length() - 1) cout << ']';
- }
- return 0;
- }
RAW Paste Data