Cod sursa(job #730189)

Utilizator alexarnautuArnautu Alexandru alexarnautu Data 5 aprilie 2012 22:16:15
Problema Text Scor 50
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.79 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 cuv, chars;
    char c, cprev;

    chars = 0;
    cuv = 0;

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

    if((c >= 'a' && c <= 'z') || (c >= 'A' && c <='Z'))
       chars++;

    cprev = c;

    while(!feof(iFile))
    {
        fscanf(iFile, "%c", &c);
        if(c == '-' && ((cprev >= 'a' && cprev <= 'z') || (cprev >= 'A' && cprev <='Z')))
            cuv++;
        if(c == ' ')
            cuv++;
        if((c >= 'a' && c <= 'z') || (c >= 'A' && c <='Z'))
            chars++;
        cprev = c;
    }

    fprintf(oFile, "%lld", chars/cuv);

    fclose(iFile);
    fclose(oFile);

    return 0;
}