Cod sursa(job #567206)

Utilizator Antonius74Antonius Cezar Hegyes Antonius74 Data 29 martie 2011 20:38:34
Problema Potrivirea sirurilor Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.59 kb
#include <cstdio>
#include <vector>
#include <string.h>
#define LG_MAX 2000000
using namespace std;

int main()
{
	freopen ("strmatch.in","r",stdin);
	freopen ("Strmatch.out","w",stdout);
	
	unsigned int anz=0,aux=0,j=0,m;
	char a[LG_MAX],b[LG_MAX];
	vector <int> pos;
	scanf ("%s %s", a,b);
	
	for (unsigned int i=0;i<strlen(b);i++)
		if (b[i]==a[0])
		{
			m=i;
			while (b[m]==a[j])
			{
				aux++;
				m++;
				j++;
			}
			if (aux==strlen(a))
			{
				anz++;
				pos.push_back (i);
			}
			j=0;
			aux=0;
		}
	
	printf ("%d\n", anz);
	for (unsigned int i=0;i<pos.size();i++)
		printf ("%d ", pos[i]);
}