P2562 [AHOI2002] Kitty猫基因编码
显示CE,请大佬帮忙debug+解释
CE评测信息:
/tmp/compiler_9o5tzp1v/src: 在函数‘void gene(std::string)’中:
/tmp/compiler_9o5tzp1v/src:10:14: 错误:‘substr’ was not declared in this scope; did you mean ‘strstr’?
10 | gene(substr(0,s.length()/2));
| ^~~~~~
| strstr
代码:
#include <bits/stdc++.h>
using namespace std;
void gene(string s){
int sum=0,sum_=0;
for(int i=0;i<(int)s.length();i++)s[i]-'0'?sum_++:sum++;
if(sum==(int)s.length())cout<<'A';
else if(sum_==(int)s.length())cout<<'B';
else{
cout<<'C';
gene(substr(0,s.length()/2));
gene(substr(s.length()/2,s.length()/2));
}
}
int main(){
string s;
cin>>s;
gene(s);
return 0;
}