Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
113280 彭士宝 31统计单词数 C++ Accepted 1 MS 292 KB 472 2025-03-15 16:27:22

Tests(10/10):


Code:

#include <iostream> #include <string> #include <sstream> // 用于istringstream using namespace std; int main() { string text; getline(cin, text); // 读取整行输入 // 使用istringstream来分割字符串 istringstream iss(text); int wordCount = 0; string word; // 逐个读取单词 while (iss >> word) { wordCount++; } // 输出单词数量 cout << wordCount << endl; return 0; }