Cod sursa(job #1987296)

Utilizator llalexandruLungu Alexandru Ioan llalexandru Data 30 mai 2017 10:26:16
Problema Text Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.64 kb
#include <fstream>
#include <cstring>
#define NM 2000000

using namespace std;

ofstream fout("text.out");

FILE * fin;

char x;
long long nr, lng, total, sz;

int main()
{
    int i;
    fin = fopen("text.in", "r");
    lng=0;
    nr=0;
    total=0;
    while (fscanf(fin, "%c", &x)!=EOF)
    {
        if (isalpha(x))
        {
            lng++;
        }
        else
        {
            if (lng)
            {
                nr++;
                total+=lng;
            }
            lng=0;
        }
    }
    if (lng)
    {
        nr++;
        total+=lng;
    }
    fout<<total/nr;
    return 0;
}