Cod sursa(job #72557)
Utilizator | Data | 14 iulie 2007 12:44:07 | |
---|---|---|---|
Problema | Text | Scor | 90 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.37 kb |
#include<stdio.h>
char c;
long int nl,nc,m,ntl;
int main()
{
FILE *f=fopen("text.in","rb");
while(fscanf(f,"%c",&c)!=EOF)
{ if((('a'<=c)&&('z'>=c))||(('A'<=c)&&('Z'>=c))) nl++;
else if(nl){nc++;ntl+=nl;nl=0;}
}
fclose(f);
f=fopen("text.out","w");
if(nc)
{ m=ntl/nc;
fprintf(f,"%ld\n",m);
}
else fprintf(f,"%ld\n",nl);
fclose(f);
return 0;
}