Cod sursa(job #2940169)

Utilizator Luka77Anastase Luca George Luka77 Data 14 noiembrie 2022 22:20:33
Problema Text Scor 70
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.75 kb
#include <bits/stdc++.h>
using namespace std;

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

inline bool word(char c)
{
    return ((c >= 'a' && c <= 'z') || (c >= 'A' && c <='Z'));
}

int main()
{
    int words = 0, letter = 0;
    string s;
    while(fin >> s)
    {
        if(word(s[0]))
        {
            words++;
            for(int i=0;i<s.length();++i)
            {
                if(s[i] == '-')
                {
                    words++;
                }
                if(!word(s[i]))
                {
                    letter--;
                }
            }
            letter+=s.length();
        }
    }
    if(words == 0)
    {
        fout << '0';
    }
    fout << letter / words;
}