Cod sursa(job #2910546)

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

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