Pagini recente » Cod sursa (job #2922641) | Cod sursa (job #3258532) | Cod sursa (job #1684825) | Cod sursa (job #1326412) | Cod sursa (job #533052)
Cod sursa(job #533052)
#include <cstdio>
#include <cctype>
#define MAX 1024*1024
int main(){
char T[MAX+100];
int c, wlength, wcount, i, word;
freopen("text.in", "r", stdin);
freopen("text.out", "w", stdout);
c = fread(T, sizeof(char), MAX+100, stdin);
wcount=0; wlength=0; word=0;
for(i=0; i<c; i++){
if(isalpha(T[i])){
wlength++;
word=1;
}
else if(word){
wcount++;
word=0;
}
}
if(word)
wcount++;
if(!wlength || !wcount)
printf("0\n");
else
printf("%d\n", wlength/wcount);
return 0;
}