Cod sursa(job #2696201)

Utilizator MateiAruxandeiMateiStefan MateiAruxandei Data 15 ianuarie 2021 15:48:37
Problema Text Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.64 kb
#include <bits/stdc++.h>

#define NMAX 10000005
using namespace std;

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

char sir[NMAX];

int main()
{
    int cnt = 0,  nrcuv = 0;
    while(fin.getline(sir, NMAX))
    {
        int lg = strlen(sir);
        for(int i = 0; i < lg; ++i)
        {
            int j = i;
            while(isalpha(sir[j]) && j < lg)
                ++j;
            cnt += j - i;

            if(j > i)
                ++nrcuv;
            i = j;
        }
    }

    if(nrcuv == 0)
    {
        fout << 0 << '\n';
        return 0;
    }
    fout << cnt / nrcuv << '\n';
    return 0;
}