Cod sursa(job #212030)

Utilizator GappPaun Catalin Gapp Data 4 octombrie 2008 09:11:23
Problema Text Scor 30
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.67 kb
#include <fstream>
#include <string>

using namespace std;

bool isText(char txt, bool mode = false) {
	
	if((txt >= 65 && txt <= 90) || (txt >= 97 && txt <= 122)) return 1;

	return 0;

}

int main() {

	ifstream fin("text.in");
	ofstream fout("text.out");

	string	text = "";
	int		lCount = 0;
	int		wCount = 0;

	getline(fin, text);

	for(int i = 0; i < text.size(); i++) {
		// Count the letters
		if(isText(text[i])) lCount++;

		// Count the words
		if(i > 1 && (text[i] == 32 || text[i] == 44 || text[i] == 45 || text[i] == 33 || text[i] == 63 || text[i] == 46) && isText(text[i-1], true)) wCount++;
	}

	fout<<lCount / wCount;

	return 0;

}