Cod sursa(job #1251726)

Utilizator roxana.istratePoenaru Roxana roxana.istrate Data 29 octombrie 2014 20:46:37
Problema Text Scor 40
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.43 kb
#include <iostream>
#include <string>
#include <cctype>
using namespace std;

int main(){
	string str;
	freopen("text.in", "r", stdin);
	freopen("text.out", "w", stdout);
	std::getline(std::cin, str);
	int len = str.size(), letters = 0, words = 0;
	for(int i = 0; i < len; i++){
		if(isalpha(str[i])){
			if(i == 0 || !isalpha(str[i-1])){
				words++;
			}
			letters++;
		}
	}
	printf("%d\n", letters/words);
	return 0;
}