Cod sursa(job #782340)

Utilizator budulaiSuman Dinu budulai Data 26 august 2012 20:48:03
Problema Text Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.64 kb
#include<iostream>
#include<fstream>

#include <math.h>

using namespace std;

int main()
{
	ifstream infile;
	ofstream outfile;
	

	infile.open ("text.in");

	
	char c;
	bool word = false;
	long chars = 0;
	long total = 0;
	while(!infile.eof())
	{
		infile.read(&c, 1);
		//infile >> c;
		
		if((c >= 'a' && c <='z') || (c >= 'A' && c <= 'Z'))
		{
			chars++;
			word = true;
		}
		else
		{
			if(word)
				total ++;
			word = false;
		}
	}

	if(word) total ++;
	//cout << chars;
	//cout << total;

	infile.close();

	outfile.open ("text.out");
	outfile << chars / total;
	outfile.close();

	return 0;
}