Cod sursa(job #2451914)

Utilizator pregoliStana Andrei pregoli Data 28 august 2019 18:59:57
Problema Text Scor 30
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.7 kb
#include <bits/stdc++.h>
using namespace std;

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

inline unsigned getWNr(char* s)
{
    bool existWord = false;
    unsigned nr = 0;
    for (int i = 0; s[i]; i++)
        if (isalpha(s[i]))
            existWord = true;
        else if (existWord)
        {
            nr++;
            existWord = false;
        }
    if (existWord)
        nr++;
    return nr;
}

inline unsigned getLetNr(char* s)
{
    unsigned nr = 0;
    for (int i = 0; s[i]; i++)
        if (isalpha(s[i]))
            nr++;
        return nr;
}

int main()
{
    char s[100];
    fin.getline(s, 100);
    fout << getLetNr(s) / getWNr(s);
    return 0;
}