Cod sursa(job #382353)

Utilizator toniobFMI - Barbalau Antonio toniob Data 13 ianuarie 2010 14:57:47
Problema Text Scor 30
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.78 kb
#include <fstream>
#include <string>
using namespace std;

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

char s [ 1<<21 ];
int cntl, cntc;

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

void citire ()
{
	in.getline ( s, 1<<21 );
}

void procesare ()
{
	if ( litera ( s [ 0 ] ) ) ++cntc, ++cntl;
	bool cuvant = false;
	for ( int i = 1; s [ i ]; ++i )
	{
		if ( litera ( s [ i ] ) )
		{
			++ cntl;
			if(!cuvant)
				++cntc;
			cuvant = true;
		}
		else
			cuvant = false;
		
		//if ( litera ( s [ i ] ) && !litera ( s [ i - 1 ] ) ) ++cntc;
	}
}

void afisare ()
{
	if ( cntc == 0 ) out << "0";
	else out << cntl / cntc;
}

int main ()
{
	citire ();
	procesare ();
	afisare ();
	
	return 0;
}