Cod sursa(job #583880)

Utilizator caen1c a e n caen1 Data 23 aprilie 2011 03:04:27
Problema Text Scor 100
Compilator c Status done
Runda Arhiva de probleme Marime 0.49 kb
/**
 * user: caen1
 * file: infoarena/text.c
 * date: 23 apr 2011
**/
#include <stdio.h>
#include <ctype.h>

#define IN "text.in"
#define OUT "text.out"

int main(void) {

	long len_text = 0, nr_cuv = 0, cuv = 0;
	char ch;

	freopen(IN, "r", stdin);
	freopen(OUT, "w", stdout);

	while((ch = getchar()) != EOF) {

		if(!cuv && isalpha(ch)) ++nr_cuv, cuv = 1, ++len_text;
		else if(cuv && isalpha(ch)) ++len_text;
		else if(cuv && !isalpha(ch)) cuv = 0;
	}

	printf("%ld", len_text / nr_cuv);

	return 0;
}