Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
132563 郝王骏程 31统计单词数 C++ Compile Error 0 MS 0 KB 509 2025-10-08 20:04:54

Tests(0/0):


Code:

#include<iostream> // cin\cout\endl #include<cstdio> //scanf()\printf() #include<cstring> // strcpy()\strcat()\strcmp()\strlen()\memset() #include<cmath> //sqrt()\pow()\abs()\ceil()\floor()\max()\min() using namespace std; int main(){ string s; getline(cin,s); int a=s.size,c=0,s=0; for(int i=0;i<=a-1;i++){ if(s[i]==' '&&c!=0){ c=0; s+=1; } else c++; } if(c>0) s+=1; cout<<s; return 0; }


Run Info:

Main.cc: In function 'int main()':
Main.cc:10:13: error: cannot convert 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size, std::allocator >' from type 'std::__cxx11::basic_string::size_type (std::__cxx11::basic_string::)() const noexcept {aka long unsigned int (std::__cxx11::basic_string::)() const noexcept}' to type 'int'
     int a=s.size,c=0,s=0;
             ^
Main.cc:10:22: error: conflicting declaration 'int s'
     int a=s.size,c=0,s=0;
                      ^
Main.cc:8:12: note: previous declaration as 'std::__cxx11::string s'
     string s;
            ^