Cod sursa(job #26733)

Utilizator xtephanFodor Stefan xtephan Data 5 martie 2007 20:52:14
Problema Text Scor 60
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.48 kb
#include<stdio.h>
#include<string.h>


int main()
{
char s[255];
char *p;

int r, cuv=0,lit=0;
FILE *f=fopen("text.in", "r");
FILE *g=fopen("text.out", "w");

if(f==NULL) printf("fiserul tarane!!");
else
{
while(!feof(f))
	{
	fgets(s, 255, f);
	p=strtok(s,"., !-\n\t:;");
	while(p)
		{
		cuv++;
		lit+=strlen(p);
		p=strtok(NULL, "., !-\n\t:;");
		}
	}
}
printf("cuvinte: %d litere:%d\n", cuv,lit);

r=lit/cuv;
fprintf(g, "%d", r);
fcloseall();
return 0;
}