Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- int main()
- {
- int s_count = 0, f_str = -1, l_str = -1;
- bool f = false;
- string str, str_in;
- cin >> str >> str_in;
- for(int i=0; i<=str.size()-str_in.size(); i++){
- if(str[i] == str_in[0]){
- int in = 0;
- for(int j=0; j<str_in.size(); j++){
- if(str[i+j] == str_in[j])
- in++;
- if(in == str_in.size()){
- s_count++;
- if(!f){
- f_str = i;
- f = !f;
- }
- if(f)
- l_str = i;
- }
- }
- }
- }
- cout<<s_count<<endl;
- if(f_str > -1) cout<<f_str<<endl;
- if(l_str > -1) cout<<l_str;
- }
Add Comment
Please, Sign In to add comment