int reverse(int a){
if(a/10==0){
return a;
}
int temp=1;
int b=a;
while (b/10>0){
temp*=10;
b=b/10;
}
return a%10*temp+reverse(a/10);
}
語言c++
不在遞歸函數中進行輸出,不使用string方法
int reverse(int a){
if(a/10==0){
return a;
}
int temp=1;
int b=a;
while (b/10>0){
temp*=10;
b=b/10;
}
return a%10*temp+reverse(a/10);
}
語言c++
不在遞歸函數中進行輸出,不使用string方法
本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。