Cod sursa(job #2773709)

Utilizator Dragono63Stanciu Rares Stefan Dragono63 Data 8 septembrie 2021 13:37:59
Problema Text Scor 60
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.13 kb
#include <fstream>

using namespace std;

/**********************************/
/// INPUT / OUTPUT

ifstream f("text.in");
ofstream g("text.out");
/**********************************/
/// GLOBAL DECLARATIONS

int ans, wordCount, letterCount;
char ch, prev_ch;
/**********************************/
/// FUNCTIONS

void Solution();
void Output();
/**********************************/
///-----------------------------------------
bool IsInAlphabet(char ch)
{
    return ('a' <= ch && ch <= 'z') ||
            ('A' <= ch && ch <= 'Z');
}
///-----------------------------------------
inline void Solution()
{
    f.get(prev_ch);

    if (IsInAlphabet(prev_ch))
    {
        wordCount ++;
        letterCount += 1;
    }

    while (f.get(ch))
    {
        if (!IsInAlphabet(ch))
        {
            if (IsInAlphabet(prev_ch))
                wordCount ++;
        }
        else
        {
            letterCount ++;
        }
        prev_ch = ch;
    }
}
///-----------------------------------------
inline void Output()
{
    g << letterCount / wordCount;
}
///-----------------------------------------
int main()
{
    Solution();
    Output();
    return 0;
}