Pagini recente » Cod sursa (job #1562131) | Cod sursa (job #2710224) | Cod sursa (job #1399707) | Cod sursa (job #2462181) | Cod sursa (job #384621)
Cod sursa(job #384621)
#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 >> noskipws >> 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;
}