Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
3432 | 莫业祁 | 31单词的长度 | C++ | Compile Error | 0 MS | 0 KB | 302 | 2024-06-08 09:59:38 |
# include<iostream> using namespace std; int main(){ string s1; cin>>s1; int n=s1.size; int s=0; for(int i=0;i<n;i++){ if(s1[i]==" "){ cout<<s; if(i!==n-1) cout<<","; s=0; } else s++; } return 0; }
Main.cc: In function 'int main()': Main.cc:7:14: error: cannot convert 'std::basic_string<_CharT, _Traits, _Alloc>::size, std::allocator >' from type 'std::basic_string::size_type (std::basic_string::)()const noexcept (true) {aka long unsigned int (std::basic_string::)()const noexcept (true)}' to type 'int' int n=s1.size; ^ Main.cc:10:19: warning: comparison with string literal results in unspecified behaviour [-Waddress] if(s1[i]==" "){ ^ Main.cc:10:19: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] Main.cc:12:15: error: expected primary-expression before '=' token if(i!==n-1) cout<","; ^