leetcode171.Excel表列序號

題目

https://leetcode-cn.com/problems/excel-sheet-column-number/
簡單 數學

我的題解

無思路。

思路

題解

c

int titleToNumber(char * s){
    int size = strlen(s);
    int rev = 0;
    for(int i = 0; i<size; i++)
    {
        rev += (s[i]-'A' + 1) * pow(26, size-i-1);
    }
    
    return rev;
}

總結

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章