Cod sursa(job #721136)

Utilizator swim406Teudan Adina swim406 Data 23 martie 2012 12:43:38
Problema Text Scor 70
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.45 kb
#include<fstream>
#include<string>
using namespace std;
int main() {
	ifstream f("text.in");
	ofstream g("text.out");
	char x,y;
	int countwords=0,length=0;
	x=f.get();
	if((x>='a' && x<='z') || (x>='A' && x<='Z')) length++;
	while(f.peek()!=EOF) {
		y=f.get();
		if((y>='a' && y<='z') || (y>='A' && y<='Z')) {
			length++;
			if(!((x>='a' && x<='z') || (x>='A' && x<='Z')))
				countwords++;
		}
		x=y;
	}
	g<<length/countwords;
	return 0;
}