| Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|
| 61940 | 杨宜炜 | 只出现一次的字符 | C++ | Compile Error | 0 MS | 0 KB | 281 | 2023-12-16 14:35:51 |
#include<bits/stdc++.h> using namespace std; int main(){ string s; cin>>s; int l=s.size; int a[127]={0}; for(int i=0;i<l;i++){ a[s[i]]++; } for(int i=0;i<l;i++){ if(a[s[i]]==1){ cout<<s[i]<<endl; return 0; } } cout<<"no"; }
Main.cc: In function 'int main()':
Main.cc:7: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 l=s.size;
^
Main.cc:10:12: warning: array subscript has type 'char' [-Wchar-subscripts]
a[s[i]]++;
^
Main.cc:13:12: warning: array subscript has type 'char' [-Wchar-subscripts]
if(a[s[i]]==1){
^