168. Excel Sheet Column Title
2016-03-21 10:24
447 查看
Given a positive integer, return its corresponding column title as appear in an Excel sheet.
For example:
Credits:
Special thanks to @ifanchu for adding this problem and creating all test cases.
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.
public class Solution { public String convertToTitle(int n) { String ret = ""; while(n>0){ int a = n%26; n = n/26; if(a==0){ret='Z'+ret;n=n-1;}else{ ret=(char)('A'-1+a)+ret; } } return ret; } }
相关文章推荐
- iOS MBProgressHUD 之带底板的加载提示
- Smobiler基于.NET框架开发移动应用内部系统—周报日志等功能(开发日志四)
- Android Studio快捷键
- JavaScript之链表操作
- 【bzoj2820】【YY的gcd】【莫比乌斯反演】
- 用jquery实现两个div的隐藏与显示
- Java static——拾遗
- Android开发Eclipse常用快捷键
- 实现视图控制器一次 dismissViewController 两个视图控制器
- oracle的sqlldr的使用总结
- 在创建一个Dialog时,发生的错误: Unable to add window -- token null is not for an application
- Python 数据结构与算法——归并排序
- LeetCode-linked-list-cycle-ii
- 设计模式——策略模式
- java总结输入流输出流
- 用户故事驱动的敏捷开发 – 2. 创建backlog
- Jenkins 十二: 集成 selenium 测试
- 2月国内网民地域分布12强:河南网民激增 排名第二
- 机器学习笔记—再谈广义线性模型
- 如何在ScrollView中嵌套ListView