题目:
Write a program to print a histogram of the lengths of words in its input. It is easy to draw the histogram with the bars horizontal; a vertical orientation is more challenging.
水平格式
#include <stdio.h>
#define IN 1
#define OUT 0
void main(){
int c,state,length;
c = state = length = 0;
while((c = getchar()) != EOF){
if(c == ' '||c == '\n'||c == '\t'){
if(state == IN){
putchar(':');
for(int i = 0; i < length; i++){
putchar('*');
}
putchar('\n');
}
state = OUT;
length = 0;
}
else {
state = IN;
putchar(c);
length++;
}
}
}
垂直格式
#include <stdio.h>
#define IN 1
#define OUT 0
#define MAX_WORD_COUN