题目
//像10进制一样进行 转换 只是要从0开始记录
class Solution { public: string convertToTitle(int n) { char a; string str=""; while(n>0){ int tmp = (n-1)%26; str = char(tmp+'A') + str; n = (n-1)/26; } return str; } };
171 Excel Sheet Column Number
class Solution { public: int titleToNumber(string s) { int n = s.size(); int sum = 0; for(int i = 0; i<n; i++){ int tmp = s[i]-'A' + 1; sum = sum * 26 + tmp; } return sum; } };