Run ID:117092

提交时间:2025-04-13 16:38:54

#include <iostream> #include <sstream> #include <vector> using namespace std; int main() { string input; getline(cin, input); // 读取整行输入 istringstream iss(input); vector<int> wordLengths; string word; // 使用字符串流分割单词 while (iss >> word) { wordLengths.push_back(word.length()); } // 输出单词长度,用逗号分隔 for (size_t i = 0; i < wordLengths.size(); ++i) { cout << wordLengths[i]; if (i < wordLengths.size() - 1) { cout << ","; } } return 0; }