一行,一段英文,中间可能包含空格、英文字符、数字,及标点符号,不含回车键。总字符数不超过10000。
一行,一个正整数,该文章的单词数。
样例:
To be or not to be is a question.
9
代码:
#include<bits/stdc++.h>
using namespace std;
int main()
{
string s;
int a=0;
while(cin>>s)
{
a++;
}
cout<<a;
return 0;
}
我不明白while循环中的条件放一个cin>>s是什么意思和怎么循环执行这个条件的。
字符串求字节数string
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-