Cod sursa(job #3159713)

Utilizator MihaiZ777MihaiZ MihaiZ777 Data 21 octombrie 2023 20:19:12
Problema Text Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.67 kb
#include <iostream>
#include <fstream>
using namespace std;

ifstream fin("text.in");
ofstream fout("text.out");


bool IsLetter (char c) {
    return ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z');
}

int main() {

    long long wordLen = 0;
    long long wordCount = 0;
    bool shouldBeNewWord = true;
    char c;

    while (fin.get(c)) {
        if (IsLetter(c)) {
            if (shouldBeNewWord) {
                wordCount++;
                shouldBeNewWord = false;
            }
            wordLen++;
        }
        else {
            shouldBeNewWord = true;
        }

    }

    fout << wordLen / wordCount << '\n';

    return 0;
}