Pagini recente » Cod sursa (job #2916963) | Cod sursa (job #352292) | Cod sursa (job #2425641) | Cod sursa (job #2528943) | Cod sursa (job #2485376)
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
ifstream fin("strmatch.in"); ofstream fout("strmatch.out");
string a, b;
int n; string c;
int occurrences(string t,string p){
int res=0;
int j=0;
for(int z=0; z<=t.length()-p.length(); z++){
j=0;
for(int i=z; i<p.length()+z; i++){
if(t[i]==p[j]){if( (j+1)==p.length()){res++; c+=to_string(z)+' '; break;}else{j++;} }
else{if(i-z>0){z=i-1;}break;}
if(res>=1000){break;}
}
if(res>=1000){break;}
}
return res;
}
int main(){
fin>>a>>b;
fout<<occurrences(b, a)<<endl<<c;
return 0;
}