Cod sursa(job #516408)

Utilizator padreatiAurelian Tutuianu padreati Data 23 decembrie 2010 22:18:00
Problema Text Scor 90
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.57 kb
#include <cstdlib>
#include <fstream>
#include <iostream>

using namespace std;

int main() {

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

    char c;
    int words = 0, total_size = 0, size = 0;
    while ((c = in.get()) && (c != EOF)) {
        if (c >= 'A' && c <= 'z') {
            size++;
            total_size++;
        } else if (size != 0) {
            size = 0;
            words++;
        }
    }
    if (size != 0) {
        words++;
    }

    out << (words ? total_size / words : 0);
    cout << (words ? total_size / words : 0);
    return 0;
}