Cod sursa(job #1312189)

Utilizator Tzappy90Mihalache Constantin Tzappy90 Data 8 ianuarie 2015 23:21:39
Problema Text Scor 100
Compilator c Status done
Runda Arhiva de probleme Marime 0.52 kb
#include <stdio.h>
#include <string.h>
int isletter(char a)
{
	if( ('a'<=a && a<='z') || ('A'<=a && a<='Z'))
		return 1;
	return 0;
}
int main()
{
	long int letter=0,word=0;
	int start=0;
	char c;
	FILE *in = fopen("text.in","r");
	FILE *out = freopen("text.out","w",stdout);
	c = getc(in);
	while(c!=EOF)
	{
		if(isletter(c))
		{
			letter++;
			if(!start)
			{
				word++;
			}
			start = 1;
		}
		else
			start = 0;
		c = getc(in);
	}
	if(word)
		printf("%ld\n",letter/word);
	else
		printf("%d\n",0);
	fclose(in);
	return 0;
}