Cod sursa(job #879568)

Utilizator howsiweiHow Si Wei howsiwei Data 15 februarie 2013 17:23:07
Problema Potrivirea sirurilor Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.58 kb
#include <fstream>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
using namespace std;

int main() {
	ifstream fin("test13.in");
	ofstream fout("strmatch.out");
	char a[2000000], s[2000000];
	fin >> a >> s;
	//cout << a << ' ' << s;
	char * match[1002];
	int i=0;
	match[0]=s;
	//cout << (match[1]=strstr(match[0],a));
	while (true) {
		match[min(i+1,1001)]=strstr(match[min(i,1001)]+1,a);
		if (match[min(++i,1001)]==NULL) break;
	}
	fout << i-1 << '\n';
	cout << i-1 << '\n';
	i=min(i,1001);
	for (int j=1; j<i; ++j) {
		fout << match[j]-s << ' ';
	}
	return 0;
}