Cod sursa(job #2251996)

Utilizator vescaDamian-Teodor BELES vesca Data 2 octombrie 2018 11:22:52
Problema Text Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.58 kb
#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;
}