Cod sursa(job #2232478)

Utilizator AndreiVisoiuAndrei Visoiu AndreiVisoiu Data 19 august 2018 15:18:26
Problema Text Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.62 kb
#include <cstdio>

using namespace std;

inline bool let(char a) {
    return (a >= 'a' && a <= 'z') || (a >= 'A' && a <= 'Z');
}

int main()
{
    freopen("text.in", "r", stdin);
    freopen("text.out", "w", stdout);
    char c = 0;
    int nrc = 0, lc = 0,
        inc = -1, sf = -1, p = 0;
    while(scanf("%c", &c) != EOF) {
        p++;
        if(let(c)) {
            if(inc == -1) inc = p;
            sf = p;
        } else
            if(inc != -1)
                nrc++, lc += sf-inc+1, inc = -1;
    }

    if(inc != -1)
       nrc++, lc += sf-inc+1;

    printf("%i", lc/nrc);
    return 0;
}