Adding to a number's figures for it to become a palindrome

Hi. I've been trying to do this for about 3 days but I just can't figure it out.
I want to make a program that adds to a number's figures for it to become a palindrome. What I am talking about is basically like this:
If we have 3112, we have to add 1 to the 2 in the end for the number to become a palindrome(2+1=3, so 3113).
If we have 47724, we have to add 5 to the 2 for the number to become a palindrome(5+2=7, so 47774).
So I want a program that does this and shows me how much was added to one of the figure. Also, if there are more figures which have to be modified, the values which are added to those figures should sum up, then show the sum.
For example: 56412, so we should add 5 to the 1(1+5=6) and 3 to 2(2+3=5), so we get 56465, and since we added 5 and 3, the solution is 5+3, which is 8.
If I were you I would put the chars in a std::string or a char array and then compare the right to the left, if the right agrees then work inwards and if not treat the char as a number again and then work out the difference etc... A recursive function to iterate through the string | array would probably help here.
Topic archived. No new replies allowed.