简单未考虑标点符号
#include <stdio.h>
#define MAX_WORD_LEN 10
#define BLANK 0
#define IN_WORD 1
#define START 2
main()
{
int c, word_len, last_ch, i, j, len_array[MAX_WORD_LEN+]; for(i=; i<MAX_WORD_LEN+; i++){
len_array[i] = ;
} i = ;
last_ch = START; while((c=getchar()) != EOF){
if (c == ' ' || c == '\t' || c == '\n'){
if (last_ch == IN_WORD){
if (i > MAX_WORD_LEN){
len_array[MAX_WORD_LEN]++;
}else{
len_array[i-]++;
}
i = ;
}
last_ch == BLANK;
}else{
last_ch = IN_WORD;
i++;
}
}
for (i=; i<MAX_WORD_LEN+; i++){
if (i == MAX_WORD_LEN){
printf(">10 ");
}else{
printf("%3d ", i+);
}
j = len_array[i];
while(j--){
printf("-");
}
printf("\n");
}
}