Cod sursa(job #1471715)

Utilizator mihai_trizDamian Mihai mihai_triz Data 14 august 2015 23:17:16
Problema Text Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.63 kb
// Text - http://www.infoarena.ro/problema/text
// Mihai Damian 8.14.2015 MM.DD.YYYY

#include <fstream>
#include <cstdio>

using namespace std;

int main()
{
    char x;
    unsigned long long n_cuv = 0, n_lit = 0;
    bool ok = false;

    FILE *f;
    f = fopen("text.in", "r");

    while (fscanf(f, "%c", &x)!=EOF)
    {
        if ((x >= 'a' && x <= 'z') || (x >= 'A' && x <='Z'))
        {
            n_lit ++;
            if (!ok) {n_cuv ++; ok = true;}
        }
        else ok = false;

    }

    fclose(f);

    ofstream g("text.out");

    g << n_lit / n_cuv ;

    g.close();


    return 0;
}