Cod sursa(job #2187993)

Utilizator DawlauAndrei Blahovici Dawlau Data 26 martie 2018 21:15:48
Problema Text Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.44 kb
#include<fstream>
#include<cctype>

using namespace std;

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

int main(){

    char c;
    int wordLen = 0, wordsLen = 0, wordsCnt = 0;

    while(fin >> noskipws >> c){

        if(isalpha(c))
            ++wordLen;
        else if(wordLen){

            ++wordsCnt;
            wordsLen += wordLen;
            wordLen = 0;
        }
    }
    fout << wordsLen / wordsCnt;
}