Cod sursa(job #1558920)

Utilizator NephthysAndrei Nephthys Data 29 decembrie 2015 19:48:32
Problema Text Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.45 kb
#include <fstream>
#include <cstring>

std::fstream in("text.in", std::ios::in), out("text.out", std::ios::out);

int main() {
	char c;
	unsigned int words, letters;
	bool found;
	found = false;
	words = 0;
	letters = 0;
	while (in.get(c)) {
		if (isalpha(c)) {
			letters++;
			found = true;
		} else {
			if (found == true) {
				found = false;
				words++;
			}
		}
	}
	out << (words == 0 ? 0 : (letters / words));
	in.close();
	out.close();
	return 0;
}