Leetcode#171 Excel Sheet Column Number

原题地址

注意从1开始索引,所以记得+1

代码:

 1 int titleToNumber(string s) {
 2         int res = 0;
 3         
 4         for (int i = 0; i < s.length(); i++) {
 5             res *= 26;
 6             res += s[i] - 'A' + 1;
 7         }
 8         
 9         return res;
10 }
原文地址:https://www.cnblogs.com/boring09/p/4268484.html