Cod sursa(job #1349182)

Utilizator andy94Andrei Ursache andy94 Data 20 februarie 2015 00:25:19
Problema Text Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.79 kb
//============================================================================
// Name        : Text.cpp
// Author      : Andrei
// Version     :
// Copyright   : Your copyright notice
// Description : Text - InfoArena
//============================================================================

#include <iostream>
#include <stdlib.h>
#include <stdio.h>
using namespace std;

int main() {

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

	int w = 0;
	int l = 0;

	char c;
	while (!feof(in)) {
		c = fgetc(in);
		if (('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z')) {
			w++;
			while (!feof(in)
					&& (('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z'))) {
				l++;
				c = fgetc(in);
			}
		}

	}

	int r = l / w;
	fprintf(out, "%d", r);

	fclose(in);
	fclose(out);

	return 0;
}