Cod sursa(job #541577)

Utilizator PsychoRoAlex Buicescu PsychoRo Data 25 februarie 2011 12:16:19
Problema Potrivirea sirurilor Scor 14
Compilator cpp Status done
Runda Arhiva educationala Marime 0.5 kb
#include<fstream.h>
#include<string.h>
#include<stdlib.h>
ifstream fin("strmatch.in");
ofstream fout("strmatch.out");
int main()
{
	int nr=0;
	char c[101], s[101], *p;
	fin.get(c, 100);
	fin.get();
	fin.get(s, 100);
	//for(i=1;i<=strlen(s);i++)
	//if(strstr(s,c)!=0)
		//fout<<i;
	p=strstr(s,c);
/*	while(p)
	{
		nr++;
		p=strstr(p,c);
		fout<<p-c<<' ';
	}
	fout<<'\n';
	fout<<nr;
	*/
	while(p)
	{
		p=strstr(strlen(s)+p,c);
		nr++;
		fout<<p-c;
		
		
	}
	fout<<nr;
	return 0;
}