Cod sursa(job #515863)

Utilizator padreatiAurelian Tutuianu padreati Data 22 decembrie 2010 16:24:11
Problema Text Scor 40
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.66 kb
#include <cstdlib>
#include <fstream>
#include <iostream>

using namespace std;

int main() {

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

    char* s = new char[1000001];
    in.getline(s, 1000001);

    int size = 0;
    int words = 0;
    int total = 0;
    int i = 0;
    while (s[i] != '\0') {
        char c = s[i];
        if (c >= 'A' && c <= 'z') {
            size++;
            i++;
            continue;
        }
        if (size != 0) {
            words++;
            total += size;
            size = 0;
        }
        i++;
    }
    if (size != 0) {
        words++;
        total += size;
    }

    out << total / words;

    return 0;
}