实验4(统计文本单词个数)
2014-11-16 09:16
288 查看
#include <stdio.h> int count_word(char *str); void main() { char str1[100]; int sum=0; puts("请输入一个字符串:"); gets(str1); sum=count_word(str1); printf("这里有 %d 个单词\n",sum); } int count_word(char *str) { int count,flag,state; char *p; count=0; state=0; p=str; while(*p!='\0') { if(*p==' ') flag=0; else if(state==0) { state=1; count++; } p++; } return count; }
老师,为何两次结果是一样的?哪里错了吗?
相关文章推荐
- 《数据结构》实验四 字符串和多维数组之统计文本单词个数
- 第四章实验:统计文本单词的个数
- 实验四-1 统计文本单词的个数
- C#统计文本单词的个数
- c++ 统计英文文本中每个单词的词频并且按照词频对每行排序
- Python实现统计文本当中单词的数量,
- 统计一个英文文本的单词词频
- 山东理工ACM【1180】C语言实验——单词统计
- 用hash表统计文本文件中每个单词出现的频率
- 用python统计文件夹下文本中的单词个数
- 统计文本英文单词总个数,并列出每个单词的个数
- 对文本中不同单词出现的次数统计
- 循环-06. 统计一行文本的单词个数
- 【ThinkingInC++】4、统计txt文本中单词的个数
- 统计文本单词个数,并个数大小按序排列 C#
- 应用散列表和外拉链表统计文本中单词个数
- C语言实验题——单词统计
- 3.2.1 泛型例子,泛型字典统计文本中的单词数
- 【编程珠玑】第十五章--字符串:统计文本中单词数量(C++的Map&C的结构体实现&POJ2418)
- 统计文本单词频率————软件工程第一次作业