Cod sursa(job #1469408)

Utilizator FairPlay94George Cioroiu FairPlay94 Data 8 august 2015 11:09:51
Problema Text Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.1 kb
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <cmath>
#include <climits>
#include <list>
#include <iomanip>
#include <cstdlib>
#include <fstream>
#include <map>
#include <algorithm>
#include <string>

using namespace std;

bool conditie(char c) {
    return ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'));
}

int main() {
    //freopen("text.in", "r", stdin);
    freopen("text.out", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    ifstream f("text.in");
    int lungime = 0, numarCuvinte = 0, lungimeText = 0;
    char text[1500000];
    while (true) {
        if (f.eof())
            break;
        f >> noskipws >> text[lungimeText];
        lungimeText++;
    }
    for (int i = 0; i < lungimeText; i++) {
        if (conditie(text[i])) {
            numarCuvinte++;
            for ( ; i < lungimeText && conditie(text[i]); i++)
                lungime++;
            i--;
        }
    }
    if (numarCuvinte == 0)
        cout << 0;
    else
        cout << lungime / numarCuvinte;

    return 0;
}