Cod sursa(job #1303333)

Utilizator alexandru.ghergutAlexandru-Gabriel Ghergut alexandru.ghergut Data 27 decembrie 2014 21:02:38
Problema Text Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.48 kb
#include <fstream>

using namespace std;

int main()
{   
    char c;
    int totalLength = 0, words = 0, length = 0;

    ifstream f("text.in");
    while (f.get(c))
    {
        if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
            length++;
        else if (length)
        {
            totalLength += length;
            words++;
            length = 0;
        }
    }
    f.close();

    ofstream g("text.out");
    g << totalLength / words;
    g.close();

    return 0;
}