您的位置:首页 > 其它

单词统计

2013-12-22 15:57 127 查看
Time Limit: 1
Sec Memory
Limit: 64 MB

Submit:
125 Solved: 80

[Submit][Status][Web
Board]

Description

从键盘输入一行字符,统计其中单词的个数,各单词以空格分隔,且空格数可以是多个。

Input

输入只有一行句子。仅有空格和英文字母构成。

Output

单词的个数。

Sample Input

stable marriage  problem Consists     of Matching members

Sample Output

7

#include

#include

using namespace std;

int main()

{char a[1000];

//char c,d;

gets(a);

int i,n=1;

for(i=0;;i++)

if(a[i+1]=='\0')

break;

else if(a[i]==' '&&a[i+1]!=' ')

n++;

cout<<n<<endl;

return 0;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: