Cod sursa(job #1251727)

Utilizator roxana.istratePoenaru Roxana roxana.istrate Data 29 octombrie 2014 20:49:11
Problema Text Scor 40
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.48 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++;
		}
	}
	if(words == 0)
		printf("0\n");
	else
		printf("%d\n", letters/words);
	return 0;
}