知识点:

函数:递归。

总结:

写了2种解法:递归与非递归。感觉还是非递归更好点。

#include <iostream>
using namespace std;

// 解法:递归

void fun(int n);

int main() {
    int n;
    cin >> n;
    int res;

    fun(n);

    return 0;
}

void fun(int n) {
    if (n < 10) {
        cout << n;
    } else {
        cout << n % 10;
        fun(n / 10);
    }
}

// 解法:非递归
/*
int main() {
    int n;
    cin >> n;
    int res;

    while (n) {
        cout << n % 10;
        n /= 10;
    }

    return 0;
}
*/