#include <stdio.h>
#include <math.h>
int reverse(int, int);
int main()
{
int number = 1234567890;
printf("Reversed number is %d\n", reverse
(number
, 0)); return 0;
}
int reverse (int n, int power) {
static int reversed_number = 0;
int digit = n % 10;
if (n == 0) {
return reversed_number;
}
reversed_number
= digit
+ reversed_number
* pow(10, power
);
if (power == 0) {
reverse(n/10, power+1);
} else {
reverse(n/10, power);
}
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxtYXRoLmg+CgppbnQgcmV2ZXJzZShpbnQsIGludCk7CgppbnQgbWFpbigpCnsKICAgIGludCBudW1iZXIgPSAxMjM0NTY3ODkwOwogICAgCiAgICAKICAgIHByaW50ZigiUmV2ZXJzZWQgbnVtYmVyIGlzICVkXG4iLCByZXZlcnNlKG51bWJlciwgMCkpOwogICAgcmV0dXJuIDA7Cn0KCmludCByZXZlcnNlIChpbnQgbiwgaW50IHBvd2VyKSB7CiAgICBzdGF0aWMgaW50IHJldmVyc2VkX251bWJlciA9IDA7CiAgICBpbnQgZGlnaXQgPSBuICUgMTA7CiAgICBpZiAobiA9PSAwKSB7CiAgICAgICAgcmV0dXJuIHJldmVyc2VkX251bWJlcjsKICAgIH0KICAgIHJldmVyc2VkX251bWJlciA9IGRpZ2l0ICsgcmV2ZXJzZWRfbnVtYmVyICogcG93KDEwLCBwb3dlcik7CiAgICAKICAgCiAgICBpZiAocG93ZXIgPT0gMCkgewogICAgCXJldmVyc2Uobi8xMCwgcG93ZXIrMSk7CiAgICB9IGVsc2UgewogICAgCXJldmVyc2Uobi8xMCwgcG93ZXIpOwogICAgfQp9Cg==