Cod sursa(job #867341)

Utilizator ToTaLPivaru Paul Mihai ToTaL Data 29 ianuarie 2013 16:40:08
Problema Text Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.56 kb
#include <fstream>
#include <iostream>
#include <string.h>
using namespace std;

ifstream fin("text.in");
ofstream fout("text.out");

int main()
{
	char buffer;
	bool gotWord = false;
	int i,alen,wlen,tlen=0,wcount=0;
	while(!fin.eof())
	{
		fin.get(buffer);
		
		if((buffer >= 'a' && buffer <= 'z') || (buffer >= 'A' && buffer <= 'Z'))
		{
			wlen++;
			gotWord = true;
		}
		else
		{
			if(gotWord)
			{
				tlen += wlen;
				wcount++;
			}
			gotWord = false;
			wlen = 0;
		}
	}
	if(gotWord)
	{
		tlen += wlen;
		wcount++;
	}
	cout<<wcount<<' '<<tlen;
	fout<<tlen/wcount;
}