Cod sursa(job #584025)

Utilizator xaphariusMihai Suteu xapharius Data 23 aprilie 2011 17:02:32
Problema Text Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.57 kb
#include <stdio.h>
using namespace std;

int main(){

	FILE *ipf = fopen("text.in", "r");
	FILE *opf = fopen("text.out", "w");

	bool este = false;
	char c;
	int charCount = 0, wordCount = 0;

	while (!feof(ipf)){
		fscanf(ipf, "%c", &c);
		//fprintf(opf, "%c", c);
		if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
			if (!este){
				este = true;
				charCount++;
				wordCount++;
			}
			else
				charCount++;
		else
			if (este){
				este = false;	
				//fprintf(opf, "\n");
			}
			else;	
	}

	fprintf(opf, "%d", charCount/wordCount);

	fclose(ipf);
	fclose(opf);

	return 0;
}