标签:
LeetCode 171 Excel Sheet Column Number
c语言实现:
int titleToNumber(char* s) { int num = 0; char c; while(c = *s++) { num = num*26 + c - ‘A‘ + 1; } return num; }
c++实现:
class Solution { public: int titleToNumber(string s) { int ret = 0; for(int i = 0; i < s.size(); i ++) ret = ret*26 + (s[i]-‘A‘+1); return ret; } };
LeetCode 171 Excel Sheet Column Number
标签:
原文地址:http://www.cnblogs.com/walker-lee/p/4963907.html