文章
5
粉丝
63
获赞
0
访问
2.5k
vector是多余的,忽略掉就好
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
string str;
getline(cin, str);
int count = 0;
vector<int> nums;
for (int i = 0; i < str.size(); i++) {
if (str[i] == '.') break;
if (str[i] != ' ') {
count++;
}
if (str[i] != ' ' && (str[i + 1] == ' ' || str[i + 1] == '.')) {
nums.push_back(count);
cout << count << " ";
count = 0;
}
}
return 0;
}
登录后发布评论
暂无评论,来抢沙发