Cod sursa(job #1435668)

Utilizator GeiGeiGeorge Cioroiu GeiGei Data 14 mai 2015 00:28:09
Problema Text Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.67 kb
//0046
#include <cstdio>
#include <cstring>

bool litera(char c) {
    if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
        return true;
    return false;
}

int main() {
    FILE* fi = fopen("text.in", "rt");
    FILE* fo = fopen("text.out", "wt");

    long long l = 0, n = 0;
    bool cn = true;

    while (true) {
        char c = fgetc(fi);
        if (c == EOF)
            break;
        if (litera(c)) {
            l++;
            if (cn) {
                n++;
                cn = false;
            }
        }
        if (!litera(c) && !cn)
            cn = true;
    }
    fprintf(fo, "%lld", (long long)(l / n));

    return 0;
}