#include <stdio.h>
#include <stdlib.h>
void main(){
int num;
void pnum(int n);
printf("输入一个整数:");
scanf("%d",&num);
pnum(num);
}
void pnum(int n){
int i = 10;
if(n/i != 0)
{
pnum(n/i);
printf("%c",n%10+'0');
/*这里的顺序很重要,如果颠倒了,就变成了倒序输出字符串*/
}
else
printf("%c",n+'0');
}
运行结果