Cod sursa(job #1339638)

Utilizator atty97Toth Attila atty97 Data 11 februarie 2015 00:40:16
Problema Text Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.54 kb
#include <fstream>
#include <string>
using namespace std;

int main()
{
	ifstream in_f("text.in");
	ofstream out_f("text.out");
	string text = "";
	
	while (!in_f.eof())
	{
		getline(in_f, text);
	}

	int size = text.length(), letters = 0, words = 0, avg = 0;

	for (int i = 0; i < size; i++)
	{
		if ((text[i] >= 'a' && text[i] <= 'z') || (text[i] >= 'A' && text[i] <= 'Z'))
		{
			if (text[i - 1] == ' ' || (text[i - 1] == '-'))
				++words;
			++letters;
		}
	}

	avg = letters / words;
	out_f << avg;

	return 0;
}