![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C程序设计语言
Kuzurio
新手入门
展开
-
C程序设计语言 练习1-14
题目: 编写一个程序,打印输入中各字符的频度直方图。 #include <stdio.h> #include <stdlib.h> #define ASC 256 int main() { int code[ASC] = {0}; //数组初始化 int ch; while((ch = getchar()) != EOF){ ++ code[ch]; //每个字符有专属的ASCII码,根据码的位置统计次数 }原创 2020-11-18 16:13:17 · 198 阅读 · 0 评论 -
C程序设计语言 练习1-13
题目: 编写一个程序,打印输入中单词长度的直方图。 /* 水平直方图 */ #include <stdio.h> #include <stdlib.h> #define MAX 200 #define IN 1 #define OUT 0 int main() { int length[MAX]; int ch, i, j, flag = 0; int state = OUT; while((ch = getchar()) != EOF)原创 2020-11-15 17:01:39 · 322 阅读 · 0 评论 -
单词计数(C语言)
题目:统计行数,单词数与字符数,这里单词的定义是不包含任何空格,换行,制表符的字符序列。 方法1: 该方法是自己没看书中代码,根据代码块下面思路提示编写的代码; #include <stdio.h> #include <stdlib.h> #define OUT 0 #define IN 1 int main() { int nl, nw, nc; nl = nw = nc = 0; int state = OUT; int ch; fo原创 2020-11-14 10:51:44 · 933 阅读 · 0 评论