Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
118966 | 毛靖平 | 31统计单词数 | C++ | Accepted | 1 MS | 284 KB | 437 | 2025-05-11 14:51:53 |
#include<iostream> #include<cstdio> #include<cstring> #include<cmath> using namespace std; int main(){ string s2; int t=0,m=0; getline(cin,s2); int len=s2.length(); for(int i=0;i<len;i++){ if(s2[i]!=' '){ t++; } else if(s2[i]==' '&& t !=0){ t=0; m++; } if(i==len-1&&t!=0){ m++; } } cout<<m; }