How do I remove this for loop to make it completely Recursive?
Here’s the link to my code: https://ide.codingblocks.com/s/88373
Move all x at end
how your code giving the correct ans when i debug the code i got the wrong ans eg- axbxp ans is abxpx pls explain your code control
u can do like that
Not getting the correct output. Check the code with input axbxp
For each recursive call, the first x encountered is moved towards last, I am running the loop to do that for all of the x present in the input string.
it is beacuse i have only made change to ur function and ur code contain a cout at last also so therefore it is printing ans and the original string
now check
but if x is encounter and the next element is also x then you are swaping x with another x and at that place x will be left
Doesn’t matter because the i is being incremented at every call with the recursion.
Thanks man, it’s working!