Run ID:115565

提交时间:2025-03-31 20:06:19

#include <iostream> #include <string> #include <sstream> using namespace std; int main() { string input; getline(cin, input); // 读取整行输入 stringstream ss(input); string word; string lengths; while (ss >> word) { lengths += to_string(word.length()); // 计算单词长度并转为字符串 if (!ss.eof()) { // 如果不是最后一个单词,添加逗号 lengths += ","; } } cout << lengths << endl; return 0; }