Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
115565 | 胡海峰老师 | 31单词的长度 | C++ | Accepted | 1 MS | 276 KB | 521 | 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; }