Ad
Code
Diff
  • int reverse_int_recc(int num, int rev) {
        return (num == 0) ? rev : reverse_int_recc(num / 10, rev * 10 + (num % 10));
    }
    
    int reverse_int(int num) {
        return reverse_int_recc(num, 0);
    }
    
    • int reverse_int(int num)
    • {
    • int rev = 0;
    • num *= 10;
    • while(num /= 10)
    • rev = rev * 10 + num % 10;
    • return rev;
    • }
    • int reverse_int_recc(int num, int rev) {
    • return (num == 0) ? rev : reverse_int_recc(num / 10, rev * 10 + (num % 10));
    • }
    • int reverse_int(int num) {
    • return reverse_int_recc(num, 0);
    • }