Cod sursa(job #382347)

Utilizator toniobFMI - Barbalau Antonio toniob Data 13 ianuarie 2010 14:51:47
Problema Text Scor 40
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.66 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;
	for ( int i = 1; s [ i ]; ++i )
	{
		if ( litera ( s [ i ] ) ) ++ cntl;
		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;
}