Cod sursa(job #384625)

Utilizator toniobFMI - Barbalau Antonio toniob Data 20 ianuarie 2010 16:05:03
Problema Text Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.64 kb
#include <fstream>
#include <string>
using namespace std;

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

int cntl, cntc;

bool litera ( char c )
{
	return ( c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' );
}

int main ()
{
	//if ( litera ( s [ 0 ] ) ) ++cntc, ++cntl;
	char s;
	bool cuvant = false;  int i = 1;
	in >> s;
	if(litera(s))
	{
		++ cntl;
		++ cntc;
		cuvant = true;
	}
	while ( in >> noskipws >> s )
	{
		if ( litera ( s ) )
		{
			++ cntl;
			if(!cuvant)
				++cntc;
			cuvant = true;
		}
		else
			cuvant = false;
	}
	
	if ( cntc == 0 ) out << "0";
	else out << cntl / cntc;
	
	return 0;
}