Cod sursa(job #614215)

Utilizator a_h1926Heidelbacher Andrei a_h1926 Data 5 octombrie 2011 20:59:22
Problema Text Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.8 kb
#include <iostream>
#include <fstream>
#include <cstring>

#define LMax 1000005

using namespace std;

int L, LWords, NWords;

inline bool Letter (char C)
{
    if ((int)C-'a'>=0 and (int)C-'z'<=0)
    {
        return true;
    }
    if ((int)C-'A'>=0 and (int)C-'Z'<=0)
    {
        return true;
    }
    return false;
}

int main()
{
    ifstream fin ("text.in");
    ofstream fout ("text.out");
    char C;
    while (!fin.eof ())
    {
        fin.get (C);
        if (Letter (C))
        {
            do
            {
                ++LWords;
                fin.get (C);
            }
            while (!fin.eof () and Letter (C));
            ++NWords;
        }
    }
    fout << LWords/NWords << "\n";
    fin.close ();
    fout.close ();
    return 0;
}