Pagini recente » Cod sursa (job #1872653) | Cod sursa (job #1221084) | Cod sursa (job #1952739) | Cod sursa (job #1917683) | Cod sursa (job #1160174)
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <malloc.h>
#include <string.h>
int count(char string[])
{
int wlength=0;
int nwords=0;
int inword=0;
int length=strlen(string);
int i;
printf("%s",string);
for(i=0;i<length;i++)
{
if(isalpha(string[i]))
{
inword=1;
++wlength;
if(i==length-1)
++nwords;
}
else
{
if(inword)
{
++nwords;
inword=0;
}
}
}
return wlength/nwords;
}
int main()
{
char string[100000];
freopen("text.in","r",stdin);
freopen("text.out","w",stdout);
scanf("%s",string);
int nwords=count(string);
printf("%d",nwords);
return 0;
}