11智能在线
新记
c语言用递归法将12345,变成54321
c语言用递归法将12345,变成54321
举报该文章
相关建议 2015-11-13
//#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;
}
温馨提示:内容为网友见解,仅供参考
当前网址:
https://11.t2y.org/zz/vf74ps84p28s42ff8p.html
其他看法
无其他回答
相似回答
大家正在搜
相关问题
C语言新手求教把12345变成54321
C语言递归;输出结果12345 54321,问:54321怎...
C语言编写程序 :输入一个正整数,将其逆序输出。例如,输入1...
编写一个递归函数,实现将任意正整数按反序输出,如输入1234...
C语言程序,输入12345怎么输出54321?
C语言里要将输入的12345输入54321怎么办?用除10求...
c语言问题 为什么输出来是12345 而不是54321
C语言设计:用递归法将一个整数逆序输出