Pagini recente » Cod sursa (job #2569988) | Cod sursa (job #497120) | Cod sursa (job #1398277) | Cod sursa (job #1492686) | Cod sursa (job #34234)
Cod sursa(job #34234)
#include<stdio.h>
int main()
{
long count=0,sum=0,current=0;
char c,sw=0;
freopen("text.in","r",stdin);
while(!feof(stdin))
{
scanf("%c",&c);
if((c>='a' && c<='z') || (c>='A' && c<='Z'))
{current++;sw=1;}
else
{
if(sw==1){sw=0;count++;sum+=current;current=0;}
}
}
if((c>='a' && c<='z') || (c>='A' && c<='Z'))
{current++;sw=1;}
else
{
if(sw==1){sw=0;count++;sum+=current;current=0;}
}
fclose(stdin);
freopen("text.out","w",stdout);
if(count==0){printf("0");}
else{printf("%ld",sum/count);}
fclose(stdout);
return 0;
}