Cod sursa(job #2232945)

Utilizator LivcristiTerebes Liviu Livcristi Data 21 august 2018 18:02:36
Problema Text Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.69 kb
#include <iostream>
#include <fstream>
char c;
int nr, lng, lngt;
using namespace std;
int e_lit(char &a)
{
    if(a >= 'a' && a <= 'z')
        return 1;
    if(a >= 'A' && a <= 'Z')
        return 1;
    return 0;
}
int main()
{
    ifstream f("text.in");
    ofstream g("text.out");
    while(f.get(c))
    {
        if(e_lit(c))
        {
            lng++;
        }
        else
        {
            if(lng)
            {
                nr++;
                lngt += lng;
                lng = 0;
            }
        }
    }
    if(e_lit(c) && lng)
    {
        lngt += lng;
        nr += 1;
    }
    g << lngt / nr;
    f.close();
    g.close();
}