c语言小菜题

来源:百度知道 编辑:UC知道 时间:2024/05/10 13:07:53
题目:用递归的方法,输入一个非负整数,结果输出这个数的逆序十进制数。
ps:用递归法

void putout(int x){
if(x == 0) return;
printf("%d", x % 10);
x = x / 10;
putout(x);
}

void main(){
int x;
scanf("%d", &x);
putout(x);
}

#include<stdio.h>

viod function(long x)
{
if((x/10)!=0)
function(x/10);
printf("%d",x%10);
}

int main()
{long a;
printf("please input a long member:\n");
scanf("%ld",a);
function(a);
return 0;
}

int function(int x)
{
if((x/10)!=0)
function(x/10);
printf(x%10);
}

if(x == 0) return(); 能表示一个非负整数?

我虽然我不会写,看了回帖感觉都不能成功~~