统计字数的小程序(1)
2013-08-19 21:10
246 查看
读取输入的的字符并报告其中的字符、单词以及行数。
c primer plus 7.7
c primer plus 7.7
#include<stdio.h> #include<stdbool.h> #include<ctype.h> #define STOP ']' int main(void) { char c; int n_character=0; int n_word= 0; int n_line = 0; int p_line = 0; bool inword = false; char prev ; printf("Please enter the strings to be analysis:\n"); prev= '\n'; while((c=getchar())!=STOP) { n_character++; if(!inword && !isspace(c)) { inword = true; n_word++; } if(inword && isspace(c)) inword = false; if(c == '\n') n_line++; prev = c; } if(prev !='\n' ) p_line = 1; printf(" charaters : %d\n words: %d\n lines: %d\n partical lines: %d\n", n_character,n_word,n_line,p_line); return 0; }
相关文章推荐
- 一个统计字数的程序
- 【软件工程】统计文章字数和出现频率较高词汇的程序实现
- (七)MapReduce字数统计程序
- 4.6 心得:统计字数程序
- 【分享】小程序表单字数统计、小程序计算textarea中字数(剩余字数)
- Hadoop自带字数统计程序wordcount异常
- 利用Foundation框架写的小程序统计文件(文件夹内文件)的所有行数(或统计字数)
- 一个统计字数的程序
- 【C语言】编写一个程序统计输入字符串中: 各个数字、空白字符、以及其他所有字符出现的次数。
- Oracle PL/SQL编程之如何实现程序来统计另一个程序的性能
- 单词词频统计程序(map set 应用)
- PHP 中如何正确统计中文字数
- 统计程序中的代码数量
- 利用Python编写一个程序 统计当前目录下的每个文件类型的文件数目
- C++第17周项目7——用程序玩文件(1)统计单词数
- Android EditText多行文本输入 字数统计 限制数量
- 简单的字数统计
- java 统计代码小程序
- java代码行统计程序
- 第十四周项目四 处理C++源代码的程序(统计main函数、简单整理格式、在代码前加行号)