Pagini recente » Cod sursa (job #2095925) | Cod sursa (job #632378) | Cod sursa (job #1331478) | Cod sursa (job #884655) | Cod sursa (job #2964582)
#include <iostream>
#include <fstream>
#include <cstring>
#include <vector>
#define MAX_N 2000005
using namespace std;
char a[MAX_N], b[MAX_N];
ifstream fin ("strmatch.in");
ofstream fout ("strmatch.out");
vector <int> contor;
int main()
{
fin.tie(0);
ios::sync_with_stdio(false);
fin.getline(a, MAX_N);
fin.getline(b, MAX_N);
int indexA=0, indexB=0, start_poz=-1;
int lenA=strlen(a);
for (indexB=0; b[indexB]!='\0'; indexB++) {
if (a[indexA]=='\0') {
contor.push_back(start_poz);
indexB=start_poz+1;
start_poz=-1;
indexA=0;
}
if (a[indexA]==b[indexB]) {
if (start_poz==-1) start_poz=indexB;
indexA++;
}
else {
if (start_poz!=-1)indexB=start_poz+1;
start_poz=-1;
indexA=0;
}
}
fout<<contor.size()<<'\n';
for (auto i : contor) {
fout<<i<<" ";
}
return 0;
}