第五章26

【题目描述】

 

键盘输入一段英文,输出其中的单词个数。

 

【输入】

 

一段英文单词

 

【输出】

 

单词的个数

 

【样例输入】

 

I love China and the people

 

【样例输出】

 

6

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
     int a=1,c;
     while((c=getchar())!='\n')
  {
    if(c==' ')
   a=a+1;
  }
  printf("%d",a);
    return 0;
}

 

posted @ 2022-11-04 12:30  aquAAA  阅读(80)  评论(0编辑  收藏  举报