Cod sursa(job #1471713)

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

#include <iostream>
#include <fstream>
#include <cstdio>

using namespace std;

void citire()
{
    char c, x;
    unsigned int n_cuv = 0, n_lit = 0;
    bool ok = false;

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

    while (fscanf(f, "%c", &x))
    {
        if (x == '\n') break;

        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();

}

int main()
{
    citire();

    return 0;
}