Pagini recente » Cod sursa (job #2572510) | Cod sursa (job #1918276) | Borderou de evaluare (job #1949968) | Cod sursa (job #2352505) | Cod sursa (job #909265)
Cod sursa(job #909265)
#include <fstream>
#include <string.h>
using namespace std;
ifstream is("text.in");
ofstream os("text.out");
int main()
{
char a[1000000];
int lungime;
long long cuvinte = 0;
long long litere = 0;
while( is >> a )
{
lungime = strlen(a);
bool esteCuvant = false;
int nrLitere = 0;
for( int i = 0; i < lungime; ++i )
{
if( (a[i] >= 'a' && a[i] <= 'z') || (a[i] >= 'A' && a[i] <= 'Z') )
{
esteCuvant = true;
nrLitere++;
}
if( a[i] == '-' && nrLitere != 0 && i < lungime - 1 && ( (a[i+1] >= 'a' && a[i+1] <= 'z') || (a[i+1] >= 'A' && a[i+1] <= 'Z') ) )
cuvinte++;
}
if( esteCuvant )
{
cuvinte++;
litere += nrLitere;
}
}
os << litere / cuvinte;
os.close();
is.close();
return 0;
}