Cod sursa(job #3159701)

Utilizator MihaiZ777MihaiZ MihaiZ777 Data 21 octombrie 2023 20:09:01
Problema Text Scor 40
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.74 kb
#include <iostream>
#include <fstream>
#include <string>
using namespace std;

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

string s;

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

int main() {
    getline(fin, s);

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

    for (char c : s) {
        if (IsLetter(c)) {
            if (shouldBeNewWord) {
                wordCount++;
                shouldBeNewWord = false;
            }
            wordLen++;
        }
        else {
            shouldBeNewWord = true;
        }

    }

    long long average = wordLen / wordCount;
    fout << average << '\n';

    return 0;
}