本题目要求读入1个正整数n,然后编写递归函数reverse(int n)实现将该正整数逆序输出。
输入格式:
输入在一行中给出1个正整数n。
输出格式:
对每一组输入,在一行中输出n的逆序数。
输入样例:
12345
结尾无空行
输出样例:
54321
结尾无空行
代码实现:
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
while(n!=0)
{
cout<<n%10;
n=n/10;
}
return 0;
}