Cod sursa(job #2158159)

Utilizator Udar27Balc Radu Udar27 Data 10 martie 2018 11:02:46
Problema Text Scor 40
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.62 kb
#include <fstream>
using namespace std;
ifstream f("text.in");
ofstream g("text.out");

bool este_litera(char c)
{
    if(tolower(c) >= 'a' && tolower(c) <= 'z')
        return true;
    return false;
}

int main()
{
    char s[256];
    f.getline(s,256);
    int i = 0, nrcuv = 0, nrchars = 0;
    while (!(s[i] >= 'a' && s[i] <= 'z') && !(s[i] >= 'A' && s[i] <= 'Z'))
        ++i;
    while(s[i] != '\0')
    {
        if (este_litera(s[i]))
            nrchars++;
        if(este_litera(s[i]) && !este_litera(s[i-1]))
            nrcuv++;
        i++;
    }
    g << nrchars/nrcuv;
    return 0;
}