递归

输入4398,然后输出‘4’ ‘3’ ’9‘ ’8‘。。。。可以利用递归的性质
#include
<stdio.h>
#include
<string.h>
#include
<stdlib.h>
void fun(int x )
{
if (x == 0) {
return ;
}
else
fun(x
/ 10);

printf(
"%c\n",x % 10 + '0');
}

int main( )
{
int a, b;
while (scanf("%d",&a) != EOF)
{
fun(a);
}
return 0;
}

posted on 2011-08-12 18:47  more think, more gains  阅读(161)  评论(0编辑  收藏  举报

导航