Cod sursa(job #801569)

Utilizator Mihai22eMihai Ionut Enache Mihai22e Data 24 octombrie 2012 18:17:43
Problema Text Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.57 kb
#include<stdio.h>
#include<string.h>

using namespace std;

int n, i, length, nr, ok;
char c;

int main()
{
    FILE *f = fopen("text.in", "r");

    while(fscanf(f, "%c", &c) != EOF)
    {
        if(( c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') )
        {
            ++length;
            if(!ok)
                ++nr, ok = 1;
        }
        else ok = 0;

    }

    fclose(f);

    FILE *g = fopen("text.out", "w");

    if(!nr)
        fprintf(g, "0\n");
    else fprintf(g, "%d\n", (length / nr));

    fclose(g);

    return 0;

}