Cod sursa(job #1257188)

Utilizator laurageorgescuLaura Georgescu laurageorgescu Data 7 noiembrie 2014 13:26:34
Problema Text Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.75 kb
#include<fstream>
#include<string>

using namespace std;

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

string s;
string::iterator it;

int get_cuv() {
    int sol = 0;
    while ( it != s.end() && (*it < 'a' || *it > 'z') && (*it < 'A' || *it > 'Z') ) {
        ++ it;
    }
    while ( it != s.end() && ( (*it >= 'a' && *it <= 'z') || (*it >= 'A' && *it <= 'Z') ) ) {
        ++ it;
        ++ sol;
    }
    return sol;
}
int main() {
    int nrlit, nrcuv, x;
    getline( fin, s, (char)0 );
    it = s.begin();
    nrlit = 0; nrcuv = 0;
    while ( it != s.end() ) {
        if ( ( x = get_cuv() ) > 0 ) {
            nrlit += x;
            ++ nrcuv;
        }
    }
    fout << nrlit / nrcuv << "\n";
    fin.close();
    fout.close();
    return 0;
}