Cod sursa(job #1864813)

Utilizator TerraMGMihai Gurau TerraMG Data 1 februarie 2017 00:24:18
Problema Text Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.67 kb
#include <fstream>
#include <iostream>
#include <string.h>

using namespace std;

bool lit(char x)
{
    if (x >= 'A' && x <= 'Z')
        return 1;
    if (x >= 'a' && x <= 'z')
        return 1;
    return 0;
}

int main()
{
    ifstream e("text.in");
    ofstream g("text.out");
    int nr = 0;
    int c = 0;
    char x;
    e >> noskipws >> x;
    char p = x;
    if (lit(x) == 1)
    {
        nr++;
        c++;
    }
    while (e >> noskipws >> x)
    {
        if (lit(x) == 1)
            c++;
        if (lit(x) == 1 && lit(p) == 0)
            nr++;
        p = x;
    }
    g << c / nr;
    e.close();
    g.close();
    return 0;
}