LeetCode 168. Excel Sheet Column Title

题目

class Solution {
public:
    string convertToTitle(int n) {
        
        
        string ans="";
        
        
        while(n)
        {
           int x = (n-1) % 26;
            
           ans += ('A'+ x );
            
            n = (n-1) / 26;
        }
        
        string res="";
        
        for(int i=ans.length()-1;i>=0;i--)
        {
            res += ans[i];
        }
        
        return res;
        
    }
};
原文地址:https://www.cnblogs.com/dacc123/p/12236062.html