LeetCode Excel Sheet Column Title

class Solution {
public:
    string convertToTitle(int n) {
        if (n <= 0) {
            return "";
        }
        string res;
        while (n>0) {
            n--;
            res = (char)(n % 26 + 'A') + res;
            n /= 26;
        }
        return res;
    }
};

有些理不清,没有零的数进制,应该还是算第几个排列类型的

posted @ 2014-12-21 13:17  卖程序的小歪  阅读(92)  评论(0编辑  收藏  举报