Cod sursa(job #261271)

Utilizator ooctavTuchila Octavian ooctav Data 17 februarie 2009 23:27:01
Problema Subsir Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.86 kb
// subsir.cpp : Defines the entry point for the console application.
//

#include <stdio.h>
#include <stdlib.h>
char e[503];
char f[503];
int g[250];
int nre()
{
	int i=1;
	while(e[i]!='\n' && e[i]!=0)
		i++;
	return i;
}
int nrf()
{
	int i=1;
	while(f[i]!='\n' && f[i]!=0)
		i++;
	return i;
}
int main()
{
	
    int i,cont=0,nr=0,a=0,b=0,p=0,j,i2,j2;
    FILE *f1,*f2;
    f1=fopen("subsir.in","r");
    f2=fopen("subsir.out","w");
    fgets(e,503,f1);
    fgets(f,503,f1);
	a=nre();
	b=nrf();

	for(i=0;i<=a;i++)
		for(j=0;j<=b;j++)
			if(e[i]==f[j])
			{
				i2=i;
				j2=j;
				p=0;
				while(e[i2]==f[j2])
				{
					i2++;
					j2++;
					p++;
				}
				if(p==cont)
					nr++;
				if(p>cont)
				{
					nr=1;
					cont=p;
				}
			}

    fprintf(f2,"%d",nr%666013);
    fclose(f1);
    fclose(f2);
	return 0;
}