Cod sursa(job #34236)
Utilizator | Liviu Cristian Mirea-Ghiban bilygates2005 | Data | 20 martie 2007 14:07:22 |
---|---|---|---|
Problema | Text | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.5 kb |
#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(!feof(stdin) && (c>='a' && c<='z') || (c>='A' && c<='Z'))
{current++;sw=1;}
else
{
if(sw==1){sw=0;count++;sum+=current;current=0;}
}
}
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;
}