Cod sursa(job #2383311)

Utilizator IoanaDraganescuIoana Draganescu IoanaDraganescu Data 19 martie 2019 12:32:56
Problema Text Scor 40
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.55 kb
#include <iostream>
#include <fstream>
#include <cstring>

using namespace std;

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

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

char s[1005];

int main()
{
    int x = 0, y = 0;
    fin.getline(s, 1005);
    for (int i = 0; s[i]; i++)
    {
        if (lit(s[i]))
            x++;
        if (i != 0 && lit(s[i - 1]) && (!lit(s[i]) || fin.eof()))
            y++;
    }
    fout << x / y << '\n';
    return 0;
}