Cod sursa(job #1395146)

Utilizator AnesthesicChereches Sergiu Alexandru Anesthesic Data 21 martie 2015 01:29:46
Problema Text Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.54 kb
#include <iostream>
#include <fstream>
#include <cstring>
using namespace std;

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

string s;

int main(){
    int total=0, words=0;
    bool ok;
    s+=' ';
    while(!fin.eof()){
        getline (fin, s);
        for(int i=0; i<s.size(); i++){
            if(isalpha(s[i])) total++, ok= true;
            if(i==s.size()) break;
            if(!isalpha(s[i+1]) && ok)  words++, ok= false;
        }
    }

    if(words==0)    return 0;
    fout << total/words;
    return 0;
}