Cod sursa(job #1193578)

Utilizator muraru_georgeMuraru George Cristian 323CB muraru_george Data 1 iunie 2014 01:01:30
Problema Text Scor 0
Compilator c Status done
Runda Arhiva de probleme Marime 0.55 kb
#include <stdio.h>
#include <string.h>

#define N 1048576

int main(void)
{	
	char *v = "`~1234567890!{@#$%^&*()-}|\":+?=><,./;'[]\\";
	FILE *f_in = fopen("text.in", "rt");
	FILE *f_out = fopen("text.out", "wt");
	char s[N];
	fgets(s, 999, f_in);
	if(s[strlen(s)-1] == '\n')
		s[strlen(s)-1] = '\0';
	char *p = strtok(s, v);
	int nr_cuv = 0, lungime = 0;
	while(p)
		{
			nr_cuv++;
			lungime+=strlen(p);
			p = strtok(NULL, v);
		}
	if(nr_cuv == 0)
			nr_cuv = 1;
	fprintf(f_out, "%d", lungime/nr_cuv);
	fclose(f_in);
	fclose(f_out);
}