Cod sursa(job #499811)

Utilizator tvararuVararu Theodor tvararu Data 10 noiembrie 2010 21:02:05
Problema Text Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.66 kb
#include <fstream>
using namespace std;

int main()
{
	ifstream input("text.in");

	int iTotalLitere = 0;
	int iTotalCuvinte = 0;
	bool bAvemCuvant = false;
	
	while(input)
	{
		char chCeva;
		input.get(chCeva);
		if ((static_cast<int>(chCeva) >= 65 && static_cast<int>(chCeva) <= 90 ) ||
		    (static_cast<int>(chCeva) >= 97 && static_cast<int>(chCeva) <= 122))
		{
			iTotalLitere++;
			if(!bAvemCuvant)
			{				
				bAvemCuvant = true;
				iTotalCuvinte++;
			}
		}
		else
		{
			bAvemCuvant = false;
		}		
	}
	input.close();
	
	ofstream output("text.out");
	output << (iTotalLitere / iTotalCuvinte);
	
	output.close();
	
	return 0;
}