Cod sursa(job #2383316)

Utilizator IoanaDraganescuIoana Draganescu IoanaDraganescu Data 19 martie 2019 12:38:04
Problema Text Scor 40
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.7 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);
    for (int i = 0; s[i]; i++)
    {
        if (lit(s[i]))
            x++;
        if (i != 0 && lit(s[i - 1]) && (!lit(s[i]) || i == n - 1))
            y++;
        else if (i != 0 && lit(s[i]) && i == n - 1)
            y++;
    }
    if (y == 0)
        fout << 0 << '\n';
    else
        fout << x / y << '\n';
    return 0;
}