Kindly check my code

It is given that the output must be in sorted order. If you print in base case,it is not guaranteed that your output will be sorted. For that…instead of printing in base case…you must push it in a vector in the base case.You should then sort the resulting vector in the main before printing the final result.

You can refer this https://ide.codingblocks.com/s/285431