https://leetcode.com/problems/excel-sheet-column-title/
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
我恨进制转换,傻傻算不清。
/** * @param {number} n * @return {string} */ var convertToTitle = function(n) { var res = ""; var codeA = "A".charCodeAt(); while(n > 0){ n--; res = String.fromCharCode(codeA + n % 26) + res; n = parseInt(n / 26); } return res; };
[LeetCode][JavaScript]Excel Sheet Column Title
原文:http://www.cnblogs.com/Liok3187/p/4507977.html