Cod sursa(job #2914341)

Utilizator vlad2009Vlad Tutunaru vlad2009 Data 19 iulie 2022 17:07:54
Problema Text Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.56 kb
#include <fstream>
#include <cctype>

using namespace std;

int main() {
    ifstream fin("text.in");
    ofstream fout("text.out");
    char c;
    int cnt = 0, len = 0, words = 0;
    while (fin.get(c)) {
        if (('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z')) {
            cnt++;
        } else {
            len += cnt;
            if (cnt > 0) {
                words++;
            }
            cnt = 0;
        }
    }
    if (words == 0) {
        fout << "0";
        return 0;
    }
    fout << len / words;
    return 0;
}