统计单词数

#include <stdio.h>
int main(){
 int word,num=0;
 char ch;
 printf("input your text:\n");
    while((ch=getchar())!='\n')
        if(ch==' ')
            word=0;
        else if(word==0){
         word=1;
         num++;
  }
    printf("there are %d words all together\n",num);
    return 0;
}

posted on 2019-03-21 23:43  p201821430005  阅读(128)  评论(0编辑  收藏  举报

导航