Cod sursa(job #2916322)

Utilizator daniel23Malanca Daniel daniel23 Data 29 iulie 2022 10:13:15
Problema Text Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.4 kb
#include <cstring>
#include <fstream>
std::ifstream in("text.in");
std::ofstream out("text.out");

int main() {
    int words = 0, chars = 0;
    int length = 0;
    char x;
    while (in.get(x)) {
        if (!isalpha(x)) {
            if (length > 0) words++, chars += length;
            length = 0;
        } else {
            length++;
        }
    }

    out << chars / words;
}