码迷,mamicode.com
首页 > 其他好文 > 详细

【剑指offer】【递归】46. 把数字翻译成字符串

时间:2020-04-30 09:47:51      阅读:47      评论:0      收藏:0      [点我收藏+]

标签:code   else   return   off   字符   offer   solution   剑指offer   lse   

递归

class Solution {
public:
    int translateNum(int num) {
        if(num <= 9) return 1;
        int ba = num % 100;
        if(ba <= 9 || ba >= 26) return translateNum(num / 10);
        else return translateNum(num / 10) + translateNum(num / 100);
    }
};

【剑指offer】【递归】46. 把数字翻译成字符串

标签:code   else   return   off   字符   offer   solution   剑指offer   lse   

原文地址:https://www.cnblogs.com/Trevo/p/12806560.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!