K&R C Exercise 1-13 Solution
来源:互联网 发布:九宫格锁屏软件大全 编辑:程序博客网 时间:2024/05/06 20:44
/* * Exercise 1-13 * 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. * * fduan, Dec. 10, 2011 */#include <stdio.h>#define IN1#define OUT0#define MAX_LEN10int main(){int c, i, j, len, max_len, state;int len_word[MAX_LEN + 1] = { 0 };max_len = len = 0;state = OUT;while( ( c = getchar() ) != EOF ) {if( c != ' ' && c != '\t' && c != '\n' ){state = IN;++len;}else if( state == IN ){state = OUT;++len_word[len];max_len = ( len > max_len ) ? len : max_len;len = 0;}}for( i = 1; i <= max_len; ++i ){printf( "%2d:\t", i );for( j = 0; j < len_word[i]; ++j )putchar( '*' );putchar( '\n' );}return 0;}
- K&R C Exercise 1-13 Solution
- K&R C Exercise 1-9 Solution
- K&R C Exercise 1-12 Solution
- K&R C Exercise 1-16 Solution
- K&R C Exercise 1-17 Solution
- K&R C Exercise 1-18 Solution
- K&R C Exercise 1-19 Solution
- K&R C Exercise 1-20 Solution
- K&R C Exercise 1-21 Solution
- K&R C Exercise 1-22 Solution
- K&R C Exercise 3-1 Solution
- K&R C Exercise 2-3 Solution
- K&R C Exercise 2-4 Solution
- K&R C Exercise 2-5 Solution
- K&R C Exercise 2-6 Solution
- K&R C Exercise 2-7 Solution
- K&R C Exercise 2-8 Solution
- K&R C Exercise 2-9 Solution
- 黑马程序员.net学习笔记3----泛型。
- 如何解包/编辑/打包android系统的boot.img文件
- vim清空文件所有内容
- 第一个程序
- C语言 迷宫问题求解(顺序栈应用示例)
- K&R C Exercise 1-13 Solution
- mysql 数据库备份与恢复
- Flex中如何用贴图的方式高效地绘制虚线
- Android View 可视控件的继承关系
- mac系统--lion下出现MicrosoftIntermediateCertificates keychain的问题
- python随笔(二)
- 人一辈子都的夹着尾巴做人
- javaDouble精度问题
- 数据绑定(九)Binding的数据校验