1133: 单词个数统计
题目描述
从键盘输入一行字符,长度小于1000。统计其中单词的个数,各单词以空格分隔,且空格数可以是多个。
输入
输入只有一行句子。仅有空格和英文字母构成
输出
单词的个数
样例输入 Copy
stable marriage problem Consists of Matching members
样例输出 Copy
7
C
#include<stdio.h>
int main()
{
	int i=1,n=0;
	char a[1005];
	gets(a);
	if(a[0]!=' ')
		n=1;
	while(a[i]!='\0'){
		if(a[i-1]==' '&& a[i]!=' ')
			n++;
		i++;
	}
	printf("%d\n",n);
	return 0;
}
                                    来源:CSDN
作者:曹氏阿七
链接:https://blog.csdn.net/qq_45845830/article/details/104105112