Cod sursa(job #262931)

Utilizator ShootMeBistriceanu Andrei ShootMe Data 19 februarie 2009 19:18:41
Problema Text Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.5 kb
#include <stdio.h>
#include <string.h>



int main()
{
	FILE *in = fopen("text.in", "r");
	FILE *out = fopen("text.out", "w");

	long nbChars = 0;
	long nbWords = 0;
	char c;
	bool lastChIsLetter = false;
	while((c=getc(in))!=EOF) 
	{
		if (('a' <= c && 'z' >= c) || ('A' <= c && 'Z' >= c))
		{
			nbChars ++;
			if (!lastChIsLetter)
				nbWords ++;
			lastChIsLetter = true;
		}
		else
			lastChIsLetter = false;
	}

	fprintf(out, "%ld", nbChars/nbWords);
	fclose(in);
	fclose(out);
}