Cod sursa(job #1260977)

Utilizator LEUTzzVadastreanu Cristian-Ionut LEUTzz Data 11 noiembrie 2014 20:23:02
Problema Text Scor 100
Compilator c Status done
Runda Arhiva de probleme Marime 0.64 kb
#include <stdio.h>



void main () {

	FILE *f;
	f = fopen("text.in","r");
	int c;
	int characters = 0;
	int words = 0;
	int others = 0;
	int state = 0;
	while ((c = fgetc(f)) != EOF) {
		
		if(state == 0) {//cauta inceputul cuvintelor
			if((c >= 65 && c <=90) || (c >= 97 && c <= 122 )){
				words++;
				characters++;
				state = 1;
			}



		}else if(state == 1){//parcurge cuvantul

			if(((c >= 65 && c <=90) || (c >= 97 && c <= 122 ))){
				
				characters++;
			
			}else {
				
				state = 0;
			
			}

		}


	}
	fclose(f);
	f = fopen("text.out","w");
	fprintf(f,"%d" ,characters/words);
	fclose(f);
}