Cod sursa(job #40535)

Utilizator NastiOana nasti Nasti Data 27 martie 2007 14:51:19
Problema Text Scor 80
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.54 kb
#include<stdio.h>
#include<ctype.h>
#include<string.h>
char s[60000],*p;
int main()
{
FILE*f=fopen("text.in","r");
FILE*g=fopen("text.out","w");
long nrl=0;
long nrc=0,i;

while(!feof(f))
  {
  fscanf(f,"%s",&s);
  if(s[0]=='-')
  {}
  else
	{
	 nrc++;
	 for(i=0;i<strlen(s);i++)
	  if(isalpha(s[i]))
		nrl++;
	 if(s[strlen(s)]!='-')
			s[strlen(s)]=NULL;
	 if(s[0]=='-')
		 strcpy(s,s+1);

	  while(strchr(s,'-'))
		{
		 nrc++;
		 p=strchr(s,'-');
		 strcpy(p,p+1);
		 }
	 }
   }

fprintf(g,"%ld",nrl/nrc);
return 0;
}