Pagini recente » Cod sursa (job #615386) | Cod sursa (job #616722) | Cod sursa (job #901834) | Cod sursa (job #3280560) | Cod sursa (job #2496954)
#include <fstream>
#include <string>
using namespace std;
ifstream fin("text.in");
ofstream fout("text.out");
string s;
int main()
{
long long nlitere =0, nr_cuvinte =0, ntotal = 0 ;
bool ok = 0;
long long i =0;
while(fin>>s)
{
int i = 0;
ok =0;
while(i < s.size())
{
if((s[i]>= 'a' && s[i]<='z' )||(s[i]>='A' && s[i]<='Z'))
{
if(ok == 0)
{
ok =1;
nlitere = 1;
}
else
nlitere++;
}
else
{
if(ok == 1)
{
ntotal = ntotal + nlitere;
nr_cuvinte++;
ok = 0;
}
}
i++;
}
if(ok == 1)
{
ntotal = ntotal + nlitere;
nr_cuvinte++;
}
}
if(nr_cuvinte == 0)
{
fout<<0<<"\n";
return 0;
}
fout<<ntotal / nr_cuvinte<<"\n";
return 0;
}