Cod sursa(job #291200)

Utilizator Bit_MasterAlexandru-Iancu Caragicu Bit_Master Data 29 martie 2009 15:33:10
Problema Text Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.7 kb
#include <cstdio>

const int N = 2000000;

char s [N];

int nr_cuv,l;

bool corect(char c)
{
	if (('a' <= c)&&(c <= 'z'))
		return true;
	if (('A' <= c)&&(c <= 'Z'))
		return true;
	return false;
}

void citire()
{
	bool bloc = false;
	
	while (fgets (s+1,N,stdin) != NULL)
	{
		for (int i = 1; s[i] != 0; ++i)
			if (!bloc && corect(s[i]))
			{
				bloc = true;
				++nr_cuv;
				++l;
			}
		else
			if (bloc && !corect(s[i]))
				bloc = false;
			else
				if (bloc && corect (s [i]))
					++l;
	}
}

void afisare()
{
	printf ("%d",l/nr_cuv);
}

int main()
{
	freopen ("text.in","r",stdin);
	freopen ("text.out","w",stdout);
	citire();
	afisare();
	return 0;
}