168 Excel Sheet Column Title Excel表列名称

给定一个正整数,返回它在Excel表中相对应的列名称。
示例:
    1 -> A
    2 -> B
    3 -> C
    ...
    26 -> Z
    27 -> AA
    28 -> AB

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

实现语言:Java

class Solution {
    public String convertToTitle(int n) {
        String res="";
            while(n!=0){
                res=(char)((n-1)%26+'A')+res;
                n=(n-1)/26;
            }
        return res;
    }
}

参考:https://www.cnblogs.com/ganganloveu/p/4175848.html

posted on 2018-04-06 23:32  lina2014  阅读(172)  评论(0编辑  收藏  举报

导航