Excel Sheet Column Number
生活随笔
收集整理的這篇文章主要介紹了
Excel Sheet Column Number
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
Related to question?Excel Sheet Column Title
Given a column title as appear in an Excel sheet, return its corresponding column number.
For example:
A -> 1B -> 2C -> 3...Z -> 26AA -> 27AB -> 28
26進制轉10進制,注意以'A'而不是0開頭,因此要“+1”,跟二進制轉換成十進制一樣。
class Solution { public:int titleToNumber(string s) {int n=s.size();int result=0;int temp=1;for(int i=n-1;i>=0;i--){result=result+(s[i]-'A'+1)*temp;temp=temp*26;}return result;} };
總結
以上是生活随笔為你收集整理的Excel Sheet Column Number的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: LLC算法coding与pooling解
- 下一篇: Laplacian Eigenmaps