Cod sursa(job #533052)
| Utilizator | Data | 12 februarie 2011 22:35:07 | |
|---|---|---|---|
| Problema | Text | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.54 kb |
#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;
}
