Q 1616: [Algorithm Improvement VIP]Inverted number
Time limit: 1Sec Memory Limit: 128MB
Title Description
The “inverse” of an integer is another integer obtained by reversing the order of each digit of that integer. If an integer ends in zeros, then those zeros are omitted from its inverse. For example, the inverse of 1245 is 5421 and the inverse of 1200 is 21. Write a program that enters two integers, calculates the sum of the inverse of these two integers, and then prints the inverse of sum. Requirement: Since you need to calculate the inverse of an integer more than once in this problem, you must abstract this part of the code to a function.
Input
The input has only one line, including two integers, separated by a space.
Output
The output has only one line, the corresponding result.
Sample Input
|
|
Sample Output
|
|
C Code
Solution A
Convert an integer to a string first, then invert it, then convert it to an integer.
|
|
Solution B
Is to first delete the zeros after the integer and then invert it to form a new integer.
|
|