Cod sursa(job #2910547)

Utilizator XelaethAlexandru Obreja Xelaeth Data 22 iunie 2022 07:58:01
Problema Text Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.9 kb
#include <bits/stdc++.h>

using namespace std;
char s[1000000];
long long sum, n;
int main()
{
    ifstream f("text.in");
    ofstream g("text.out");
    while(f>>s)
    {
        bool ok = 0;
        int i;
        for(i = 0; s[i]!=NULL && !ok; i++)
            if(isalpha(s[i]))
                ok = 1;
        if(ok)
        {
            n++;
            int l = 0;
            for(i--; s[i]!=NULL; i++)
                if(isalpha(s[i]))
                    l++;
                else
                {
                    int j;
                    for(j = i; s[j]!=NULL; j++)
                        if(isalpha(s[j]))
                            {
                                n++;
                                i = j-1;
                                break;
                            }
                }
            sum+=l;
        }
    }
    g<<sum/n;
    return 0;
}