Cod sursa(job #1165426)

Utilizator hopingsteamMatraguna Mihai-Alexandru hopingsteam Data 2 aprilie 2014 18:01:52
Problema Text Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.68 kb
#include    <iostream>
#include    <fstream>

using namespace std;

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

int letters, words, S;
int isaletter(char c)
{
    if(c >= 'a' && c <= 'z')
        return 1;
    if(c >= 'A' && c <= 'Z')
        return 1;
    return 0;
}

void read()
{
    char c, cprev;
    c = '-'; cprev = '-';
    while(fin.get(c))
    {
        if(isaletter(c))
        {
            letters += 1;
        }
        else
            if(isaletter(cprev))
            {
                S += letters;
                letters = 0;
                words += 1;
            }
        cprev = c;
    }
}

int main()
{
    read();
    fout << S / words;
    return 0;
}