LeetCode 171 Excel Sheet Column Number

Problem:

Given a column title as appear in an Excel sheet, return its corresponding column number.

For example:

    A -> 1
B -> 2
C -> 3
...
Z -> 26
AA -> 27
AB -> 28

Summary:

将二十六进制数字转为十进制。

Analysis:

 class Solution {
public:
int titleToNumber(string s) {
int len = s.size();
int res = ; for (int i = ; i < len; i++) {
res += (s[len - i - ] - 'A' + ) * pow(, i);
} return res;
}
};
上一篇:C# 定积分求周长&面积原理 代码实现


下一篇:MongoDB实战性能优化