| Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|
| 113014 | 刘佳宇 | 31统计单词数 | C++ | Compile Error | 0 MS | 0 KB | 403 | 2025-03-15 10:53:15 |
#include<bits/stdc++.h> using namespace std; int main(){ string s; 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; }
Main.cc: In function 'int main()': Main.cc:22:1: error: expected '}' at end of input } ^