c语言用递归法将12345,变成54321

c语言用递归法将12345,变成54321

//#include "stdafx.h"//If the vc++6.0, with this line.
#include "stdio.h"
int func(int n,int x=0){
    if(n){
        (x*=10)+=n%10;
        return func(n/10,x);
    }
    return x;
}
int main(void){//测试一下……
    printf("%d\n",func(12345));
    return 0;
}

温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答