Cod sursa(job #643057)

Utilizator AurashCucu Aurelian Aurash Data 2 decembrie 2011 20:14:40
Problema Text Scor 40
Compilator c Status done
Runda Arhiva de probleme Marime 0.6 kb
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

char buf[1000000000+1];

int main(void)
{
	char *s;
	double nr_cuv=0;
	double lungime_cuv=0;
	freopen("text.in","r",stdin);
	freopen("text.out","w",stdout);
	while(fgets(buf,1000000000,stdin))
	{
		s=strtok(buf," ,.-;:~!?01234\"\'5678<>9=+-/!@#$%^&*(){}[]\\");
		while(s!=NULL)
		{
			++nr_cuv;
			lungime_cuv+=strlen(s);
			s=strtok(NULL," ,.-;:~!?01234\"\'5678<>9=+-/!@#$%^&*(){}[]\\");
		}
	}
	if(nr_cuv==0)
	{
		printf("0");
	}
	else
	{
		printf("%lf",floor(lungime_cuv/nr_cuv));
	}
	return 0;
}