Pagini recente » Cod sursa (job #2119595) | Cod sursa (job #2148004) | Cod sursa (job #2756511) | Cod sursa (job #282804) | Cod sursa (job #382345)
Cod sursa(job #382345)
#include <fstream>
#include <string>
using namespace std;
ifstream in ( "text.in" );
ofstream out ( "text.out" );
char s [ 1000000 ];
int cntl, cntc;
bool litera ( char c )
{
return ( c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' );
}
void citire ()
{
in.getline ( s, 1000000 );
}
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;
}