#include
using namespace std;
void Reverse_Printf_num(int n)
{
cout << n % 10;
if (n >= 10)
Reverse_Printf_num(n / 10);
}
int main()
{
int n = 0;
cin >> n;
Reverse_Printf_num(n);
return 0;
}
本文介绍了一个使用C++实现的递归函数,该函数能够逆序打印一个整数的每一位数字。通过递归调用自身处理整数的高位部分,实现了从最低位到最高位的逆序输出。
#include
using namespace std;
void Reverse_Printf_num(int n)
{
cout << n % 10;
if (n >= 10)
Reverse_Printf_num(n / 10);
}
int main()
{
int n = 0;
cin >> n;
Reverse_Printf_num(n);
return 0;
}
1023
1513

被折叠的 条评论
为什么被折叠?