Reputation: 11
The title pretty much describes my question. I cannot recall what is wrong with my code, can you help me with it?
#include <bits/stdc++.h>
using namespace std;
int p(string &s, int f, int l){
if(s[f] == s[l]){
return(s, f +1, l-1);
}
else{
return 0;
}
if(f-l == 1 || f == l){
return 1;
}
}
int main(){
string s;
cin >> s;
int f = 0;
int l = s.length()-1;
if(p(s, f, l)){
cout << "YA";
}
else{
cout << "BUKAN";
}
}
Upvotes: 1
Views: 67
Reputation: 26753
I choose to answer the question in the body, instead of the question in the title (in line with How do I ask and answer homework questions? which I also appy to "competetive programming" questions).
Some things wrong with your code:
return
in p()
can never be executed, because both branchs of the if-then-else structure before already contain a return
.return
through that function.return(s, f +1, l-1);
is probably a doomed attempt to call p()
recursively, returning instead a the result of the ,
operators and the -
calculation.Upvotes: 1