Cod sursa(job #83824)

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


int main()
{
char s[3000000],*p;
int poz1=-1,nr=0,l=0,cuv=0,rez;
FILE *f=fopen("text.in","r");


fgets(s,3000000,f);
p=s;
while(*p!='\0')
{

if(isalpha(*p) && poz1==-1)
poz1=nr;
if(!isalpha(*p) && poz1!=-1)
{
l+=nr-poz1;
cuv++;
poz1=-1;
}
p++;
nr++;
}

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