可以帮忙解释一下这个程序的调试过程吗 初次发帖 谢谢大家
#include<stdio.h>int fun(int s1,int s2){
if(s2<10)
return(s1*10+s2%10);
s1=s1*10+s2%10;
s1=fun(s1,s2/10);
return s1;
}
int main(){
printf("%d",fun(0,1234));
}
#include <stdio.h> unsigned fun( unsigned a, unsigned b ) { printf( "%u, %u\n", a, b ); if( b == 0 ) return a; return fun( a*10+b%10, b/10 ); } int main( void ) { printf( "%u\n", fun(12345,678) ); }
#include<stdio.h> int fun(int s1, int s2) { printf("%d,%d\n", s1, s2); if (s2 < 10) return(s1 * 10 + s2 % 10); s1 = s1 * 10 + s2 % 10; s1 = fun(s1, s2 / 10); return s1; } int main() { printf("%d", fun(0, 12345)); return 0; } //fun()函数为递归函数,实现将数 s2 逆序后,保存到 s1. //s1 s2 //0, 12345 //5, 1234 //54, 123 //543, 12 //5432, 1 //54321
[此贴子已经被作者于2022-2-25 13:42编辑过]