Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
115025 | 彭士宝 | 最长的单词 | C++ | Accepted | 0 MS | 264 KB | 519 | 2025-03-26 20:57:25 |
#include <iostream> #include <string> #include <sstream> using namespace std; string findLongestWord(const string& str) { stringstream ss(str); string word; string longestWord = ""; while (ss >> word) { if (word.length() > longestWord.length()) { longestWord = word; } } return longestWord; } int main() { string input; getline(cin, input); string longestWord = findLongestWord(input); cout << longestWord << endl; return 0; }