zcmu 1091 统计单词数
2016-11-17 23:04
211 查看
1091: 统计单词
Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 1689 Solved: 757[Submit][Status][Web Board]Description
输入一个正整数 repeat (0<repeat<10),做repeat 次下列运算:输入一行字符,统计其中单词的个数。各单词之间用空格分隔,空格数可以是多个。Input
见sampleOutput
见sampleSample Input
3Every night in my dreamsI see you I feel youThat is how I know you go onSample Output
568#include <iostream>#include <cstdio>#include <cstring>#include <string>#include <cmath>using namespace std;int main(){int repeat,i,flag,counts;char a[105];scanf("%d",&repeat);getchar();while(repeat--){counts=flag=0;gets(a);for(i=0;i<strlen(a);i++){while(a[i]==' ')i++;if(a[i]!=' ')//此处接下面的重点counts++;while(a[i+1]!=' ')i++;}if(a[strlen(a)-1]==' ')//重点,因为在上面的if一句中 不等于空 多加了一次 所以要剪掉counts--;printf("%d\n",counts);}return 0;}
相关文章推荐
- 统计一篇英文文章中的单词数
- 统计单词数
- 统计单词出现的次数。
- 2018-08-05 期 MapReduce实现每个单词在每个文件中坐标信息统计
- 【数据结构-trie树】trie数实现单词查询和单词统计
- 任一个英文的纯文本文件,统计其中的单词出现的个数。
- acm-统计单词个数
- Python 练习册 4-统计文本文件中单词出现的个数
- 统计一个英文文本的单词词频
- 统计语句中单词中的个数
- 【基础水题】统计单词个数
- 统计连续出现最多的单词(如何使用循环语句)
- 【C语言助教】统计文本中单词的个数!
- C语言实验题——单词统计
- Java统计单词出现频率
- 字符串之单词统计
- 关于MapReduce单词统计的例子:
- apache-storm例子:统计句子中的单词数量
- C++STL--map和set 词频统计和单词转换
- 单词统计小助(c#开源)