#include
#include
using namespace std;
string moveXs(const string& str)
{
if (str.length() <= 1)
{
return str;
}
else if (str[0] == ‘x’)
{
return moveXs(str.substr(1, (str.length() - 1))) + str[0];
}
else
{
return str[0] + moveXs(str.substr(1, str.length()));
}
}
int main() {
char str[1000];
cin>>str;
string moveXs(str);
cout<<str<<endl;
return 0;
}
Could you please correct my code
Hey @tarunasree123
int main() {
char str[1000];
cin>>str;
string ans= moveXs(str); //updated
cout<<ans<<endl;//updated
return 0;
}
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.