Cod sursa(job #154936)

Utilizator scvalexAlexandru Scvortov scvalex Data 11 martie 2008 16:46:55
Problema Text Scor 90
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.54 kb
#include <iostream>
#include <fstream>

using namespace std;

char text[2000000];

int main(int argc, char *argv[]) {
	FILE *fi = fopen("text.in", "rb");
	fread(text, 1, sizeof(text), fi);
	fclose(fi);

	int len(0),
		count(0);
	bool inword(true);
	for (char *c = text; *c; ++c) {
		if (isalpha(*c)) {
			++len;
			if (!inword)
				++count;
			inword = true;
		} else
			inword = false;
	}
	++count;

	//cout << len << " " << count << " " << len/count << endl;

	ofstream fout("text.out");
	fout << len/count << endl;
	fout.close();

	return 0;
}