Pagini recente » Cod sursa (job #580532) | Cod sursa (job #1172097) | Cod sursa (job #2475536) | Cod sursa (job #853144) | Cod sursa (job #2240632)
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int c = 0;
int ans[1000000];
int r = 0;
void strmatch(string pat, string txt){
int m = pat.length();
int n = txt.length();
for(int i = 0; i<=n-m;i++){
int j;
for(j = 0; j<m;++j){
if(txt[i+j] != pat[j]){
break;
}
}
if(j == m){
ans[r] = i;
++r;
++c;
}
}
}
int main()
{
ifstream in("strmatch.in");
ofstream out("strmatch.out");
string a, b;
in >> a >> b;
strmatch(a, b);
out << c << endl;
for(int i = 0; i < c;++i){
out << ans[i] << " ";
}
}