文章
34
粉丝
0
获赞
6
访问
995
#include<bits/stdc++.h>
using namespace std;
int main(){
string s;
while(getline(cin, s)){
int cnt = 0;
char before = ' ';
for(int i = 0; i < s.length(); i ++){
char ch = s[i];
if(!isspace(ch)){ // 当前为字母
// 判断是否为句点
if(ch != '.') cnt ++;
else if(cnt != 0) cout << cnt << " "; // 考虑句点与单词有空格的情况
} else if(!isspace(before) && isspace(ch)){ // 前一个为字母,当前为空格
cout << cnt << " ";
cnt = 0;
}
before = ch;
}
cout << "\n";
}
return 0;
}
登录后发布评论
暂无评论,来抢沙发