Cod sursa(job #395803)

Utilizator mihai995mihai995 mihai995 Data 13 februarie 2010 20:00:34
Problema Text Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.6 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;
}