Cod sursa(job #2383318)

Utilizator IoanaDraganescuIoana Draganescu IoanaDraganescu Data 19 martie 2019 12:42:41
Problema Text Scor 40
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.74 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[10005];

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