Cod sursa(job #730339)

Utilizator alexarnautuArnautu Alexandru alexarnautu Data 6 aprilie 2012 09:40:03
Problema Text Scor 20
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.69 kb
#include <cstdio>
#include <string>
#include <iostream>
using namespace std;

FILE * iFile;
FILE * oFile;

int main()
{
    iFile = fopen("text.in", "r");
    oFile = fopen("text.out", "w");

    long long int litere, cuvinte, ok;
    char c;

    ok = 0;
    litere = 0;
    cuvinte = 0;

    fscanf(iFile, "%c", &c);

    while(!feof(iFile))
    {
        if((c >= 'a' && c <= 'z') || (c >='A' && c <= 'Z'))
        {
            litere++;
            ok = 1;
        } else {
            ok = 0;
        }

        if(ok == 0 && litere != 0)
            cuvinte++;
        fscanf(iFile, "%c", &c);
    }

    fprintf(oFile, "%lld", litere/cuvinte);


    fclose(iFile);
    fclose(oFile);

    return 0;
}