Cod sursa(job #1247702)

Utilizator whodatLetitia Radulescu whodat Data 23 octombrie 2014 13:28:02
Problema Text Scor 100
Compilator c Status done
Runda Arhiva de probleme Marime 0.61 kb
#include<stdio.h>
 
int main()
{
    FILE *f = fopen("text.in", "r");
    FILE *g = fopen("text.out", "w");
     
    char ch;
    int ok = 0;
    int count = 0;
    int sum = 0;
     
    while(!feof(f))
    {
        fscanf(f, "%c", &ch);
        if((ch>='a' && ch <='z') || (ch>='A' && ch <='Z'))
        {
            sum++;
            if(!ok)
            {
                ok = 1;
                count++;
            }
        }
        else if (ok)
		{
            ok = 0;
		}
    }
    
	if(count)
		fprintf(g, "%d", sum/count);
	else
		fprintf(g, '0');
     
    return 0;
}