Excel Sheet Column Title
来源:互联网 发布:精日 知乎 编辑:程序博客网 时间:2024/05/21 23:33
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
Credits:
Special thanks to @ifanchu for adding this problem and creating all test cases.
Subscribe to see which companies asked this question
Tags
Math
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
因为这里的值是以1为基准的,而不是0,相当于26进制的数都整体减1,才能对应上从0开始的十进制数。
/** * @param {number} n * @return {string} */var convertToTitle = function(n) { if(n<=26) { return String.fromCharCode(64 + n); } var ret = ""; while(n > 0) { n--; var a = n % 26; ret = String.fromCharCode(65 + a) + ret; n = Math.floor(n/26); } return ret;};
0 0
- Excel Sheet Column Title
- Excel Sheet Column Title
- Excel Sheet Column Title
- Excel Sheet Column Title
- Excel Sheet Column Title
- Excel Sheet Column Title
- Excel Sheet Column Title
- Excel Sheet Column Title
- Excel Sheet Column Title
- Excel Sheet Column Title
- Excel Sheet Column Title
- Excel Sheet Column Title
- Excel Sheet Column Title
- Excel Sheet Column Title
- Excel Sheet Column Title
- Excel Sheet Column Title
- Excel Sheet Column Title
- Excel Sheet Column Title
- iOS初探+load和+initialize
- Android关于Theme.AppCompat相关问题
- hadoop、hbase、hive、zookeeper版本对应关系
- 第16周阅读程序——1(3)
- 软件加密技术和注册机制加密基础
- Excel Sheet Column Title
- python channels笔记--Getting started with channels
- Material Design学习3
- C++文件操作函数详解
- Jenkins自动构建时报java.io.IOException: No space left on device的解决方案
- android studio:ndk error:'D:\...\ndk-build.cmd'' finished with non-zero exit
- iOS开发-黑科技防止多次添加删除KVO出现的问题
- (补)第六周分数的雏形
- Material Design学习4