Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
113015 | 秦浩然 | 31统计单词数 | C++ | Accepted | 1 MS | 292 KB | 364 | 2025-03-15 10:53:16 |
#include<bits/stdc++.h> using namespace std; string s; int main(){ getline(cin,s); int len=s.size(); int cnt=0; bool isw=0; for(int i=0;i<len;i++){ if(s[i] != ' '){ isw = 1; } else if(s[i]==' ' && isw==1){ cnt++; isw=0; } if(i==len-1 && isw==1){ cnt++; } } cout<<cnt; return 0; }