C语言实验题——单词统计
描述
从键盘输入一行字符,统计其中单词的个数,各单词以空格分隔,且空格数可以是多个。
输入
输入只有一行句子。仅有空格和英文字母构成。
输出
单词的个数。
样例输入
stable marriage problem Consists of Matching members样例输出
7题目来源
HHUACM
题目上传者
06036
题目难度
1(0-9:0表示不确定,1表示最容易,依次逐难,9表示最难)
#include<iostream>using namespace std;int main(){ char a[1000]; int s=0; while(cin>>a) { s++; } cout<<s<<endl; return 0;}