Cod sursa(job #1427701)

Utilizator armageddon89_rAdrian D armageddon89_r Data 2 mai 2015 21:39:30
Problema Text Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.66 kb
#include <iostream>
#include <cctype>

using namespace std;

const int chunk = 1024;

int main()
{
	freopen("text.in", "r", stdin);
	freopen("text.out", "w", stdout);

	int size = 0;
	int nrw = 0;
	char buf[1024];

	bool cont = false;

	while (cin.read(buf, chunk))
	{
		int nr = cin.gcount();
		size += nr;

		if (nr && cont == true && std::isalpha(buf[0]))
		{
			nrw--;
		}

		for (int i = 0; i < nr; i++)
		{
			if (std::isalpha(buf[i]))
			{
				nrw++;
				while (i < nr && std::isalpha(buf[i++]));
				if (nr == chunk && nr == i)
				{
					cont = true;
				}
				else
					cont = false;
			}
		}
	}

	cout << size / nrw;
}