Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
133296 石水生 31统计单词数 C++ Accepted 1 MS 288 KB 461 2025-10-18 14:25:15

Tests(10/10):


Code:

#include <iostream> #include <string> using namespace std; int main() { string s; getline(cin, s); int count = 0; bool inWord = false; for (int i = 0; i < s.length(); i++) { if (s[i] != ' ') { if (!inWord) { count++; inWord = true; } } else { inWord = false; } } cout << count << endl; return 0; }