168. Excel Sheet Column Title

168. Excel Sheet Column Title

 code

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

https://leetcode.com/problems/excel-sheet-column-title/description/

原文地址:https://www.cnblogs.com/happyamyhope/p/10081131.html