Cod sursa(job #2473829)

Utilizator mihnea.tTudor Mihnea mihnea.t Data 14 octombrie 2019 12:58:11
Problema Text Scor 40
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.71 kb
#include <iostream>
#include <fstream>
#include <cstring>

using namespace std;

ifstream fin("text.in");
ofstream fout("text.out");

int nlit;

char c[1000000];

bool verifLit(char x)
{
    if ((x >= 'a' && x <= 'z') || (x >= 'A' && x <= 'Z'))
        return 1;

    return 0;
}

void cit()
{
    fin.getline(c, 1000001);

    int nrCuv = 0;

    int n = strlen(c);
    c[n] = ' ';

    n++;

    if (verifLit(c[0])) nlit++;

    for (int i=1; i < n; ++i)
    {
        char a = c[i], b = c[i-1];

        if (verifLit(b) and !verifLit(a))
            nrCuv++;

        if (verifLit(a)) nlit++;
    }

    fout << nlit / nrCuv;
}

int main()
{
    cit();
    return 0;
}