Cod sursa(job #268068)

Utilizator robertzelXXX XXX robertzel Data 28 februarie 2009 19:01:23
Problema Text Scor 100
Compilator c Status done
Runda Arhiva de probleme Marime 0.54 kb
#include <stdio.h>
#include <ctype.h>

char x;
int s, c, ok;

void citeste ()
{
	FILE * in = fopen("text.in", "r");

	while (!feof(in))
	{
		fscanf(in, "%c", &x);


		if(  !ok  && isalpha(x) )
		{
			++c;
			ok = 1;
			++s;
		}
		else if(  ok  &&  isalpha(x)  )
		{
			++s;
		}
		else if(  ok &&  !isalpha(x)  )
		{
			ok = 0;
		}
	}

	fclose(in);
}

void scrie ()
{
	FILE * out = fopen("text.out", "w");


	fprintf(out, "%d", (s/c));

	fclose(out);
}

int main ()
{
	citeste();
	scrie();

	return 0;
}