Run ID:117096

提交时间:2025-04-13 16:44:13

#include <iostream> #include <sstream> #include <vector> using namespace std; int main() { string input; // 读取一行输入 if (!getline(cin, input)) { cerr << "Error: Unable to read input." << endl; return 1; } 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; }