Cod sursa(job #764719)

Utilizator Mihai96Saru Mihai Mihai96 Data 5 iulie 2012 23:25:42
Problema Text Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.7 kb
#include <cstdio>

char cuvant[10000000];
int main(void)
{
	freopen("text.in", "r", stdin);
	freopen("text.out", "w", stdout);
	int Slitere = 0;
	int LitereCuvant = 0;
	int Cuvinte = 0;
	int i = 0;
	while(!feof(stdin))
	{
		do{
			scanf("%c", &cuvant[i]);
			if((cuvant[i] >= 65 && cuvant[i] <= 90) || (cuvant[i] >= 97 && cuvant[i] <= 122))
			{
				LitereCuvant++;
			}
			i++;
		}while(cuvant[i-1] != ' ');
		i--;
		if(i > 1)
		{
			for(int j = 0;j <= i-1;j++)
			{
				if(cuvant[j] == '-')
				{
					Cuvinte++;
				}
			}
			Cuvinte++;
		}
		Slitere += LitereCuvant;
		LitereCuvant = 0;
		i = 0;
	}
	int MedieLitere = Slitere/Cuvinte;
	printf("%d", MedieLitere);
	return 0;
}