Cod sursa(job #83837)

Utilizator bent_larsenSturzu Antonio-Gabriel bent_larsen Data 11 septembrie 2007 23:29:34
Problema Text Scor 0
Compilator c Status done
Runda Arhiva de probleme Marime 0.41 kb
#include<stdio.h>
#include<string.h>


int main()
{
char c;
int poz1=-1,nr=0,l=0,cuv=0,rez;
double n;
FILE *f=fopen("text.in","r");



for(;;)
{
c=fgetc(f);
if(!c) break;
if(isalpha(c) && poz1==-1)
poz1=nr;
if(!isalpha(c) && poz1!=-1)
{
l+=nr-poz1;
cuv++;
poz1=-1;
}
nr++;
}

//printf("l=%i\n",l);
//printf("cuv=%i",cuv);

fclose(f);
fopen("text.out","w");
rez=(int) l/cuv;
fprintf(f,"%i",rez);
fclose(f);
return 0;
}