leetcode-168. Excel Sheet Column Title
2016-04-27 22:04
405 查看
Given a positive integer, return its corresponding column >title as appear in an Excel sheet.
For example:
![](https://img-blog.csdn.net/20160427220317448)
思路:26进制转换,注意‘A’对应的是1
For example:
思路:26进制转换,注意‘A’对应的是1
class Solution { //思路:26进制转换,注意A是从1开始的,不是从0开始的 public: string convertToTitle(int n) { if(n < 1) { return NULL; } string result; char temp; while(n) { //这样%26的时候0映射的就是'A'了 n -= 1; temp = 'A' + n%26; result = temp+result; n /= 26; } return result; } };
相关文章推荐
- bzoj 1827: [Usaco2010 Mar]gather 奶牛大集会
- poj2481Cows
- iOS 动画效果
- VR焦点管理
- UVa 122 Trees on the level 建立二叉树BFS层序遍历
- linux 解压命令
- 团队项目个人每日总结(4.27)
- linux内核编程学习——草稿
- 有线与无线网络配置相关工具
- hdu2846 Repository(字典树)
- 出现—passwd:Authentication token manipulation error—错误的解决办法
- Maven实现直接部署Web项目到Tomcat
- ubuntu14.04设置开机自动挂载硬盘分区-wd
- [C语言][LeetCode][283]Move Zeroes
- 进程通信消息队列代码及一些注意点
- 薛老师软考高项学员:2016年4月27日作业
- js中运算符&& 和 || 的使用记录
- STL排序算法介绍
- 数据结构-队列的链式存储(链队列)
- leetcode-155. Min Stack