Cod sursa(job #614212)

Utilizator a_h1926Heidelbacher Andrei a_h1926 Data 5 octombrie 2011 20:54:01
Problema Text Scor 40
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;
char String[LMax];

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");
    fin.get (String, LMax, '\n');
    L=strlen (String);
    for (int i=0; i<L; ++i)
    {
        if (Letter (String[i]))
        {
            ++LWords;
            if (!Letter (String[i-1]))
            {
                ++NWords;
            }
        }
    }
    fout << LWords/NWords << "\n";
    fin.close ();
    fout.close ();
    return 0;
}