Leetcode#168. Excel Sheet Column Title(Excel表列名--进制转换)
2018-01-27 17:19
369 查看
题目
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
题意
简单题。10进制转换为26进制Python语言
class Solution(object): def convertToTitle(self, n): """ :type n: int :rtype: str """ temp = "ZABCDEFGHIJKLMNOPQRSTUVWXY" res = "" while n!=0: res = res + temp[n%26] if n%26==0: n = n - 1 n = n / 26 r = "" for i in range(len(res)-1, -1, -1): r = r + res[i] return r
C++语言
class Solution { public: string convertToTitle(int n) { string temp = "ZABCDEFGHIJKLMNOPQRSTUVWXY"; string res = ""; while(n!=0) { res = res + temp[n%26]; if(n%26==0) n = n - 1; n = n / 26; } string r = ""; for(int i=res.length()-1; i>=0; i--) r = r + res[i]; return r; } };
相关文章推荐
- excel列名和序列之间的转换
- asp.net DataTable导出Excel 自定义列名
- Excel列名 字母和数字的转换
- 【算法】Excel中的列名与数字的对应
- 数字转换成excel列名(10进制到Excel的26进制的转换函数)
- Excel Sheet Column Number 进制转换
- EXCEL表列名变为数字了怎么办?
- 用Delphi 将 Excel 列名转 0 起 数值
- 字母和数字的转换——Excel列名
- Python Excel 列名转换
- excel 列名A,B,C修订为 1,2,3的方法
- excel 列索引(数字)转列名
- LeetCode Excel Sheet Column Number(进制转换问题)
- Excel如何动态获取列名
- 171.leetcode Excel Sheet Column Number(easy)[进制转换]
- Excel sheet的列名到列序号的转换
- SQL Server带列名导出到Excel(Export to CSV with headers)的几个思路
- 使用VBA对Excel中列名称与列号之间进行转换
- php生成excel列名超过26列大于Z时的解决方法
- 读取 EXCEL的工作表名,读取选中后工作表的列名