Cod sursa(job #254091)

Utilizator alexandru92alexandru alexandru92 Data 6 februarie 2009 19:04:55
Problema Potrivirea sirurilor Scor 40
Compilator cpp Status done
Runda Arhiva educationala Marime 0.47 kb
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define InFile "strmatch.in"
#define OutFile "strmatch.out"
#define MAX 2000001
char  A[MAX],B[MAX]; 
long  v[MAX],lg=0;
int main()
{FILE *f=freopen(InFile,"rt",stdin),*g=freopen(OutFile,"wt",stdout);
	scanf("%s %s",&A,&B);
	char *p=strstr(B,A);
	while(p)
	     {v[++lg]=p-B;
	      p=strstr(p+1,A);
	     }
	printf("%ld\n",lg);
	for(long i=1;i<=lg;i++) printf("%ld ",v[i]);
fclose(f); fclose(g);
return 0;
}