Cod sursa(job #384619)

Utilizator toniobFMI - Barbalau Antonio toniob Data 20 ianuarie 2010 15:59:53
Problema Text Scor 0
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' );
}

int main ()
{
	//if ( litera ( s [ 0 ] ) ) ++cntc, ++cntl;
	
	bool cuvant = false;  int i = 1;
	while ( in >> 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;
	}
	
	if ( cntc == 0 ) out << "0";
	else out << cntl / cntc;
	
	return 0;
}