首页 > 代码库 > [leetcode]Excel Sheet Column Title

[leetcode]Excel Sheet Column Title

就是个26进制

 

class Solution {public:    string convertToTitle(int n) {        string ans = "";        while(n) {            ans = string(1, ((n - 1) % 26 + A)) + ans;            n = (n - 1) / 26;        }        return ans;    }};

 

[leetcode]Excel Sheet Column Title