Cod sursa(job #653359)

Utilizator ileacristianIlea Cristian ileacristian Data 27 decembrie 2011 20:19:00
Problema Text Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.61 kb
#include <cstdio>
#include <iostream>
using namespace std;


bool isAlpha(char c){
	if (c >= 'A' && c <= 'Z')
		return true;
	if (c >= 'a' && c <= 'z')
		return true;
	return false;
}


int main(void){
	freopen("text.in", "r", stdin);
	freopen("text.out", "w", stdout);

	char currentChar;
	int nrOfWords = 0;
	int nrOfLetters = 0;
	bool wordFlag = false;

	while(!(EOF == scanf("%c", &currentChar))){
		if(isAlpha(currentChar)){
			nrOfLetters++;
			wordFlag = true;
		}
		else if(wordFlag){
			nrOfWords++;
			wordFlag = false;
		}
	}

	printf("%d", nrOfLetters / nrOfWords);

	return 0;
}