Cod sursa(job #1808644)

Utilizator EvohuntAndrei Dana Evohunt Data 17 noiembrie 2016 22:20:35
Problema Text Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.56 kb
#include <fstream>
#include <cstring>

using namespace std;

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

char c;
int numberOfLetters = 0;
int numberOfWords = 0;
bool check;

int main() {

    while (fin.get(c)) {

        if (isalpha(c)) {
            numberOfLetters++;
            check = true;
        }
        else {
            if (check == true)
                numberOfWords++;
            check = false;
        }
    }

    fout << numberOfLetters / numberOfWords;

    fin.close();
    fout.close();

    return 0;
}