Cod sursa(job #724048)

Utilizator swim406Teudan Adina swim406 Data 26 martie 2012 10:24:46
Problema Text Scor 70
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.48 kb
#include<stdio.h>
using namespace std;
int main() {
	freopen("text.in","r",stdin);
	freopen("text.out","w",stdout);
	char x,y='a';
	int countwords=0,length=0;
	scanf("%c",&x);
	if((x>='a' && x<='z') || (x>='A' && x<='Z')) length++;
	while(scanf("%c",&y)==1) {
		//scanf("%c",&y);
		if((y>='a' && y<='z') || (y>='A' && y<='Z')) {
			length++;
			if(!((x>='a' && x<='z') || (x>='A' && x<='Z')))
				countwords++;
		}
		x=y;
	}
	printf("%d",length/countwords);
	return 0;
}