Cod sursa(job #472502)

Utilizator ilie.danilaIlie Teodor Danila ilie.danila Data 25 iulie 2010 14:09:43
Problema Potrivirea sirurilor Scor 40
Compilator cpp Status done
Runda Arhiva educationala Marime 0.62 kb
#include <fstream>
#include <string>
#include <vector>

using namespace std;

vector<size_t> solutions;

int main()
{
	ifstream f("strmatch.in");
	ofstream g("strmatch.out");

	string A,B;
	f >> A >> B;

	f.close();

	bool isOK;
	size_t position = 0;
	do
	{
		isOK = false;
		position = B.find(A, position);
		if( position != string::npos )
		{
			solutions.push_back(position);
			position++;
			isOK = true;
		}
		
	}while(isOK);

	g << solutions.size() << "\n";

	for (unsigned int i = 0; i < solutions.size() && i < 1000; i++)
		g << int( solutions[i] ) << " ";
	g << "\n";

	return 0;
}