Cod sursa(job #1570576)

Utilizator stefan_bogdanstefan bogdan stefan_bogdan Data 16 ianuarie 2016 17:23:11
Problema Text Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.72 kb
#include <iostream>
#include <stdio.h>

using namespace std;

FILE *f, *g;
char s[10000000];
int NrCuv, NrLit;

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

int main() {

    f = fopen("text.in", "r");
    g = fopen("text.out", "w");

    fscanf(f, "%s", &s);

    while (!feof(f))
    {
        for (int i = 0; s[i] != NULL; i++)
        {
            if (EsteLitera(s[i]))
            {
                NrLit++;
                if (!EsteLitera(s[i-1]) || i == 0) NrCuv++;
            }
        }
        fscanf(f, "%s", &s);
    }


    fprintf(g, "%d", NrLit/NrCuv);

    fclose(f);
    fclose(g);

    return 0;
}