Cod sursa(job #2191051)

Utilizator HerddexJinga Tudor Herddex Data 1 aprilie 2018 14:45:31
Problema Text Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.71 kb
#include <fstream>
#include <cstring>
#include <cctype>

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

int main()
{
    unsigned long numCuvinte=0, numCaractere=0;
    char previousChar, currentChar;

    fin.get(previousChar);
    if(isalpha(previousChar))
    {
        numCuvinte ++;
        numCaractere ++;
    }

    while(!fin.eof())
    {
        fin.get(currentChar);
        if(isalpha(currentChar))
        {
            numCaractere ++;
            if(!isalpha(previousChar))
                numCuvinte++;
        }
        previousChar = currentChar;
    }

    fout<<numCaractere/numCuvinte<<'\n';

    fin.close();
    fout.close();
    return 0;
}