Cod sursa(job #2476278)

Utilizator PatrickCplusplusPatrick Kristian Ondreovici PatrickCplusplus Data 18 octombrie 2019 16:35:55
Problema Text Scor 40
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.75 kb
#include <bits/stdc++.h>

using namespace std;

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

char x[1048576 + 6];
long long s, contor, c;
int main()
{
    fin.getline(x, 1048576 + 3);
    for (int i = 0; i < strlen(x); ++i)
    {
        if ((x[i] >= 'a' && x[i] <= 'z') || (x[i] >= 'A' && x[i] <= 'Z'))
        {
            ++contor;
        }
        else
        {
            if (contor > 0)
            {
                s = 1LL * s + contor;
                contor = 0;
                c = 1LL * c + 1;
            }
        }
    }
    if (contor > 0)
    {
        s = 1LL * s + contor;
        contor = 0;
        c = 1LL * c + 1;
    }
    fout << 1LL * s / c;
    fin.close();
    fout.close();
    return 0;
}