Cod sursa(job #2288239)

Utilizator MIGAAndrei Miga MIGA Data 22 noiembrie 2018 22:58:10
Problema Text Scor 10
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.75 kb
#include <fstream>

using namespace std;

int main()
{
    int NumarLitere = 0, NumarCuvinte = 0;
    char c, lastchar = -1;
    ifstream fin;
    ofstream fout;
    fin.open("text.in");
    fin >> c;
    while (!fin.eof())
    {
        if (c >= 65 && c <= 90 || c >= 97 && c <= 122)
            NumarLitere++;
        if (!(c >= 65 && c <= 90 || c >= 97 && c <= 122) && (lastchar >= 65 && lastchar <= 90 || lastchar >= 97 && lastchar <= 122))
            NumarCuvinte++;
        lastchar = c;
        fin >> c;
    }
    if (lastchar >= 65 && lastchar <= 90 || lastchar >= 97 && lastchar <= 122)
        NumarCuvinte++;
    fin.close();
    fout.open("text.out");
    fout << NumarLitere / NumarCuvinte;
    fout.close();
    return 0;
}