Cod sursa(job #569547)

Utilizator rootsroots1 roots Data 1 aprilie 2011 18:05:03
Problema Text Scor 80
Compilator cpp Status done
Runda 104 Marime 0.53 kb
#include <stdio.h>
#include <string.h>

#define Dim 1024

char sir[Dim];

int main()
{
	int A,B,cuv,N,i;

	freopen("text.in","r",stdin);

	A=0;
	B=0;
	cuv=0;

	while(!feof(stdin))
	{
		fgets(sir,Dim,stdin);
		N=strlen(sir)-1;
		for(i=0;i<=N;i++)
			if(('A'<=sir[i]&&sir[i]<='Z')||('a'<=sir[i]&&sir[i]<='z'))
			{
				A++;
				cuv=1;
			}
			else
			{
				if(cuv) B++;
				cuv=0;
			}
	}
	if(cuv) B++;

	freopen("text.out","w",stdout);

	if(B==0) printf("0\n");
	else printf("%d\n",A/B);

	return 0;
}