Cod sursa(job #1484201)

Utilizator aimrdlAndrei mrdl aimrdl Data 10 septembrie 2015 16:07:55
Problema Text Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.45 kb
#include <stdio.h>

int main (void) {
	freopen("text.in", "r", stdin);
	freopen("text.out", "w", stdout);
	
	unsigned int wlen = 0, wcount = 0;
	bool inword = false;
	char c;
	
	while (scanf("%c", &c) != EOF) {
		if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) {
			if (inword) {
				++wlen;
			} else {
				inword = true;
				++wlen;
				++wcount;
			}
		} else {
			inword = false;
		}
	}
	
	printf("%d", (wcount) ? wlen/wcount : 0);
	
	return 0;
}