#include <stdio.h>
void inverted(int); /* 函数声明 */
int main()
{
int n; /*需要逆序的整数*/
scanf("%d",&n);
inverted(n); /*调用逆序函数*/
return 0;
}
void inverted(int n)
{
if (n < 10) { /* 当数字只剩一位的时候,即第一位数,输出,变为末位,返回 */
printf("%d", n);
return;
}
/*
从后往前除以 10 取余输出,即当前 n 的最后一位
请在此补充缺失代码
继续调用逆序函数,每次调用都输出当前 n 的最后一位
*/
return;
}
输入
一个 int
型整数 。
输出
转换后的整数。
输入输出样例
样例输入 #1
复制
1234567
样例输出 #1
复制
7654321
if(n>=10)
{
printf("%d",n%10);
inverted(n/10);
}