leetcode每日刷题计划-简单篇day22

orzorz不能断了打卡我一定要在十二点之前交。。。划水一道题

面向大作业疯狂试探.jpg

Num 171 Excel表序列号

没难点。

class Solution {
public:
    int change(int i,int len)
    {
        int ans=1;
        for(int j=1;j<=len-1-i;j++)
            ans=ans*26;
        return ans;
    }
    int titleToNumber(string s) {
        int ans=0;
        for(int i=0;i<s.length();i++)
        {
            ans=ans+(int)(s[i]-64)*change(i,s.length());
        }
        return ans;
    }
};
View Code
时间才能证明一切,选好了就尽力去做吧!
原文地址:https://www.cnblogs.com/tingxilin/p/11173586.html