首页 > 其他 > 详细

LeetCode 168. Excel Sheet Column Title

时间:2020-01-27 15:27:49      阅读:98      评论:0      收藏:0      [点我收藏+]

题目

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;
        
    }
};

LeetCode 168. Excel Sheet Column Title

原文:https://www.cnblogs.com/dacc123/p/12236062.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!