Pagini recente » Clasamentul arhivei de probleme | Cod sursa (job #2620911) | Cod sursa (job #2845394) | Cod sursa (job #216105) | Cod sursa (job #2251996)
#include <fstream>
#include <iostream>
std::ifstream fin("text.in");
std::ofstream fout("text.out");
bool isLetter(char x) {
return (x >= 'A' && x <= 'Z') || (x >= 'a' && x <= 'z');
}
int main() {
char x;
bool isPrevLetter = false;
int words = 0, totalLength = 0;
fin >> std::noskipws;
while (fin >> x) {
if (isLetter(x)) {
totalLength++;
if (!isPrevLetter) {
words++;
}
}
isPrevLetter = isLetter(x);
}
fout << totalLength / words;
return 0;
}