Cod sursa(job #1524903)

Utilizator AndreiIstetulAndrei Andrei AndreiIstetul Data 14 noiembrie 2015 15:44:24
Problema Text Scor 40
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.55 kb
#include <fstream>
#include <string>
#include <sstream>
#include <cctype>

#define LMAX 1048580

typedef unsigned uint;

std::fstream in, out;
char text[LMAX];
uint words, len, llen;
bool word;

int main(int argv, char **argc)
{
	in.open("text.in", std::fstream::in);
	out.open("text.out", std::fstream::out);

	in.getline(text, LMAX - 2);

	for (uint i = 0; text[i] != NULL; ++i)
		if (std::isalpha(text[i]))
		{
			++len;
			word = true;
		}
		else if (word)
		{
			++words;
			word = false;
		}

	out << len / words;
	return 0;
}