Cod sursa(job #1259735)

Utilizator g.r.stefanStefan R Gingeoveanu g.r.stefan Data 10 noiembrie 2014 15:19:02
Problema Text Scor 0
Compilator c Status done
Runda Arhiva de probleme Marime 0.67 kb
#include<stdio.h>
#include<string.h>
#include<limits.h>

int main()
{
    FILE *input, *output;

    input = fopen ("text.in", "rt");
    output = fopen ("text.out", "wt");

    char text[INT_MAX];
    int i;
    int ChrCounter = 0;
    int WrdCounter = 0;

    fgets(text, INT_MAX, input);

    for (i=0; i<strlen(text); i++)
    {
        if ( (text[i] >= 'a' && text[i] <= 'z') || (text[i] >= 'A' && text[i] <= 'Z') )
        {
            ChrCounter++;

            if ( !(text[i+1] >= 'a' && text[i+1] <= 'z') && !(text[i+1] >= 'A' && text[i+1] <= 'Z') )
                WrdCounter++;
        }
    }

    fprintf(output, "%d" , ChrCounter/WrdCounter);
}