编写一个程序,读入用户输入的,以 .
结尾的一行文字,统计一共有多少个单词,并分别输出每个单词含有多少个字符。 (凡是以一个或多个空格隔开的部分就为一个单词)
输入格式
共一行,包含一个以 .
结尾的字符串。
输出格式
共一行,按顺序输出字符串中每个单词包含的字母的个数。
数据范围
字符串长度不超过 1000。
输入样例:
hello how are you.
输出样例:
5 3 3 3
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
int main()
{
string st;
while(cin >> st){
if(st[st.size() - 1] != '.') cout << st.size() << ' ';
else cout << st.size() - 1 << ' ';
}
return 0;
}