Cod sursa(job #905590)

Utilizator paul.chPaul Chelarescu paul.ch Data 5 martie 2013 22:39:32
Problema Text Scor 40
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.05 kb
#include<fstream>
#include<cstring>
using namespace std;
ifstream fin("text.in");
ofstream fout("text.out");
string s;
char ch;
inline void citire()
{
    getline(fin, s);
}
int main()
{
//    citire();
    long long  nr_cuv = 0, litere = 0;
//    for(long long i = 0; i <= s.length(); ++i)
//    {
//        if((s[i] >= 'a' and s[i] <= 'z') or (s[i] >= 'A' and s[i] <= 'Z'))
//        {
//            nr_cuv++;
//            while((s[i] >= 'a' and s[i] <= 'z') or (s[i] >= 'A' and s[i] <= 'Z'))
//            {
//                ++litere;
//                ++i;
//            }
//        }
//    }
    long long sol = 0, ok = 0;
    while(fin.get(ch) and ch != 10)
    {
        if((ch>='a'&&ch<='z') || (ch>='A'&&ch<='Z'))
        {
            ++litere;
            ok = 1;
        }
        else
        {
            if(ok)
            {
                ++nr_cuv;
                ok = 0;
            }
        }
//        if(ok)++nr_cuv;
    }
    if(nr_cuv != 0) sol = litere / nr_cuv;
    fout << sol;
    return 0;
}