Cod sursa(job #3272992)

Utilizator anon2718281828Iasmina Matei anon2718281828 Data 31 ianuarie 2025 22:19:50
Problema Text Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.53 kb
#include <bits/stdc++.h>
#include <regex>

using namespace std;

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

int main() {
    string s;
    string tmp;
    while (getline(in, tmp)) {
        s += tmp + " ";
    }

    long long length = 0, count = 0;
    regex r("[a-zA-Z]+");
    for (auto it = sregex_iterator(s.begin(), s.end(), r); it != sregex_iterator(); it++) {
        length += it->str().size();
        count++;
    }
    
    if (count == 0) out << 0;
    else out << length / count;

    return 0;
}