package leetcode;

public class demo_168 {
    public String convertToTitle(int columnNumber) {
        StringBuffer sb=new StringBuffer();
        while(columnNumber!=0) {
            //-1可以让余数正好处于0-25之间
            columnNumber=columnNumber-1;
            //每次出现最后一个一个字符
            int num=columnNumber%26;
            columnNumber=columnNumber/26;
            char c=(char)(65+num);
            sb=sb.append(c);
        }
        //字符串去反
        sb=sb.reverse();
        System.out.println(sb.toString());
        return sb.toString();
    }
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        demo_168 d168=new demo_168();
        d168.convertToTitle(701);
    }

}