Cod sursa(job #2516004)

Utilizator Narcis09Grecu Narcis Narcis09 Data 29 decembrie 2019 23:47:00
Problema Potrivirea sirurilor Scor 40
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.51 kb
#include <stdio.h>
#include <cstring>
using namespace std;
#define dmax 2000001
int main(){
	freopen("strmatch.in", "r", stdin);
	freopen("strmatch.out", "w", stdout);
	char a[dmax], b[dmax];
	int v[1001], n=0;
	scanf("%s", &a);
	scanf("%s", &b);
	
	int x=strlen(a);
	char *p;
	p=b;
	int k=0;
	do{
		p=strstr(p, a);
		if (p){
		++k;
		if (n<1000)
			v[++n]=p-b;
		p=p+1;
		if (strlen(p)<x)
			break;
		}	
	}while (p);
	printf("%d\n", k);
	for (int i=1;i<=n;i++)
		printf("%d ", v[i]);
/*	fin.close();
	fout.close();*/
}