c语言中统计单词数目
时间:2021-08-29 20:27:18
收藏:0
阅读:10
1、
#include <stdio.h> #include <ctype.h> #include <stdbool.h> int main(void) { char ch; bool word = false; bool space = false; int words = 0; while((ch = getchar()) != EOF) { if(!isspace(ch)) word = true; if(isspace(ch)) space = true; if(word && space) { words++; word = false; space = false; } } printf("words: %d.\n", words); return 0; }

原文:https://www.cnblogs.com/liujiaxin2018/p/15202868.html
评论(0)