Cod sursa(job #1561757)

Utilizator andreigasparoviciAndrei Gasparovici andreigasparovici Data 4 ianuarie 2016 15:09:48
Problema Text Scor 60
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.5 kb
#include <iostream>
#include <fstream>
#include <cstring>
#include <cctype>
using namespace std;
int nr,len;
char sep[]=" 1234567890-.,?/;:!~";
int main()
{
    ifstream fin("text.in");
    char c=fin.get();
    bool word=0;
    while(!fin.eof())
    {
        if(isalpha(c))
        {
            ++len;word=1;
        }
        if(strchr(sep,c) && word==1)
        {
            ++nr;
            word=0;
        }
        c=fin.get();
    }
    ofstream fout("text.out");
    fout<<len/nr;
    return 0;
}