168.Excel Sheet Column Title(28 -> AB)
2015-07-29 14:02
357 查看
Given a positive integer, return its corresponding column title as appear in an Excel sheet.
For example:
代码:
public class Solution {
public String convertToTitle(int n) {
String res = "";
while(n!=0){
res=(char)((n-1)%26+'A')+res;
n = (n-1)/26 ;
}
return res;
}
}
For example:
1 -> A 2 -> B 3 -> C ... 26 -> Z 27 -> AA 28 -> AB
代码:
public class Solution {
public String convertToTitle(int n) {
String res = "";
while(n!=0){
res=(char)((n-1)%26+'A')+res;
n = (n-1)/26 ;
}
return res;
}
}
相关文章推荐
- 图论浅析--基础知识
- iOS-UI-滚动视图2—分页查看功能
- 没有人会提醒你,你的梦想还没有实现
- 图论浅析--基础知识
- SVG实战开发学习(三)——路径
- 27个提升效率的iOS开源库推荐
- Jconsole 监控linux下的tomcat
- Android Socket tcp/udp)
- 用URL传参带特殊字符,特殊字符丢失(encode)
- win10升级$Windows.~BT文件夹删掉了的解决办法
- Atom飞行手册翻译: 1.4 小结
- STD 2015 hdu5317 打表预处理
- 存储在图的形式——邻接列表
- 逻辑串说面向对象知识点
- apktool 反编译 Input file was not found or was not readable.问题解决方案
- Win10于北京时间7月29日中午12:00正式发布
- poj 2516 Minimum Cost
- 解题笔记(30)——找含单链表的环入口点(转网上某位高手的解法)
- 红黑树的理解说明(删除)
- Android中保存和恢复Fragment状态的最好方法