#include<stdio.h>
#include<stdlib.h>
#define IN 1
#define OUT 0
void main()
{
{
char string[8000], c;
int i, num = 0, word = OUT;
gets(string);//*输入句子
for (i = 0; (c = string[i]) != '\0'; i++)
if (c == ' ')
word = OUT;//*遇到了单词
else
if (word == OUT)
{
word = IN;//*计数完毕等待下一个空格
num++;//*单词数加1
}
printf("一共有%d个单词。\n", num);
}
system("pause");
}