Given a positive integer, return its corresponding column title as appear in an Excel sheet.
For example:
1 -> A
2 -> B
3 -> C
...
26 -> Z
27 -> AA
28 -> AB
这道题要注意,这不是单纯的26进制,26进制应该是:
0 -> A
1 -> B
2 -> C
...
25 -> Z
26 -> AA
27 -> AB
那我们处理的时候就干脆吧n直接减掉1
var convertToTitle = function(n) {
var res="";
while(n>0){
res=String.fromCharCode(65+(n-1)%26)+res;
n=parseInt((n-1)/26);
}
return res;
};