Cod sursa(job #793357)

Utilizator Detrol2kGuianu Leon Detrol2k Data 2 octombrie 2012 18:24:30
Problema Text Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.44 kb
#include <fstream>
#include <ctype.h>
using namespace std;

int main()
{
	ifstream f("text.in");
	ofstream g("text.out");
	
	char c,c2;
	unsigned int wordNr=0, textLength=0;
	short int k=0;
	
	while(!f.eof())
	{
		f.get(c);
	 	if(isalpha(c))
	 	{
			textLength++;
			if(k==0)
				wordNr++;
			k=1;
	 	}
 		else
 			k=0;
	}
	
	//caz wordNr = 0
	if(wordNr==0)
	{
		g<<0;
		return 0;
	}
	
	g<<(int)textLength/wordNr;
}