#include <stdio.h>
int solve(int n)
{
int temp=n%10;
int tt;
n/=10;
if(n)
solve(n);
tt='0'+temp;
if(n)
printf(" %c", (char)tt);
else
printf("%c", (char)tt);
}
int main()
{
int n;
scanf("%d",&n);
solve(n);
return 0;
}
用递归法将一个整数n转换成字符串。例如,输入n为483,输出字符串 4 8 3,每个数字后面接一个空格用于隔开字符。
最新推荐文章于 2023-09-13 13:27:37 发布