Cod sursa(job #26782)

Utilizator xtephanFodor Stefan xtephan Data 5 martie 2007 21:18:37
Problema Text Scor 70
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.44 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,"., -!:;\t");
	while(p)
		{
		cuv++;
		lit+=strlen(p);
		p=strtok(NULL, "., -!:;_@#$%^&*()=+");
		}
	}
}

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