Pagini recente » Cod sursa (job #1205831) | Cod sursa (job #1624089) | Cod sursa (job #847580) | Cod sursa (job #406809) | Cod sursa (job #2203533)
#include <bits/stdc++.h>
using namespace std;
char c[1200];
char sep[]=". , - ; ! ?>= ";
int n,lungime,cuvinte,i;
ifstream fin("text.in");
ofstream fout("text.out");
int litera(char c)
{
if((c>='a'&&c<='z')||(c>='A'&&c<='Z'))
return 1;
}
int main()
{
fin.get(c,1200);
// cout<<c;
char *p=strtok(c,sep);
char s[150];
while(p!=NULL)
{
// cout<<p<<endl;
n=strlen(p);
strcpy(s,p);
// cout<<s<<" ";
bool ok=1;
for(i=1; i<=n&&ok==1; i++)
{
if(litera(s[i])==1)ok=1;
else ok=0;
}
if(ok=1)
{
cuvinte++;
lungime=lungime+n;
//cout<<cuvinte<<" "<<lungime<<"\n";
}
p=strtok(NULL,sep);
}
// fout<<cuvinte<<" "<<lungime<<"\n";
if(cuvinte==0)fout<<0;
else
fout<<lungime/cuvinte;
return 0;
}