Cod sursa(job #458820)

Utilizator theodora_maneaManea Theodora Maria theodora_manea Data 26 mai 2010 14:09:31
Problema Text Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.41 kb
#include <stdio.h>
#include <string.h>

char ch;
int i,n,ok,l,c,r;

int main () {
	FILE *f=fopen("text.in","r");
	FILE *g=fopen("text.out","w");
	ok=0; c=0; 
	while (!feof(f)) {
		fscanf(f,"%c",&ch);
		if ( (ch>='a' && ch<='z') || (ch>='A' && ch<='Z') ) {
			if (!ok) {
				c++;
				ok=1;
			}
			if (ok) l++;
		}
		else ok=0;
	}
	r=(int)l/c;
	fprintf(g,"%d\n",r);
	return 0;
}