Pagini recente » Cod sursa (job #2052449) | Cod sursa (job #2765356) | Cod sursa (job #1353242) | Cod sursa (job #913963) | Cod sursa (job #382355)
Cod sursa(job #382355)
#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 = 0; 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;
}