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

202. 快乐数

时间:2020-05-17 21:47:12      阅读:69      评论:0      收藏:0      [点我收藏+]

标签:int   没有   title   tle   ber   函数   str   solution   a*   

我发现力扣的环境里面没有stoi函数

int stoi(string& s) {
    int a=0,b=1;
    for (int i=0;i<s.length();i++) {
        a=a*26+(s[i]-‘A‘+1);
    }
    return a;
}

class Solution {
public:
    int titleToNumber(string s) {
        return stoi(s);
    }
};

202. 快乐数

标签:int   没有   title   tle   ber   函数   str   solution   a*   

原文地址:https://www.cnblogs.com/xyqxyq/p/12906956.html

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