Excel Sheet Column Title
2015-12-18 18:06
295 查看
Excel Sheet Column Title
Total Accepted: 45878 Total Submissions: 230128 Difficulty: EasyGiven 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
class Solution { public: string convertToTitle(int n) { string res; while(n){ int r = (n-1)%26; res.push_back('A' + r); n = (n-1)/26; } reverse(res.begin(),res.end()); return res; } };
相关文章推荐
- java重载(实现同一方法名,不同参数)
- 欢迎使用CSDN-markdown编辑器
- 黑马程序员-C语言-Xcode常用快捷键
- 分布式文件系统FastDFS设计原理
- OC 之关联对象
- 51nod 1107 斜率小于0的连线数量 (树状数组+离线化)
- java提高篇(二四)-----HashSet
- android studio 快捷键在 苹果和windows/linux的对照
- hdoj  acm   1592
- hdoj  acm   1555
- hdoj   acm   1029
- hdoj   acm    1008
- hdoj acm    1003
- Practice and Knowledge
- 我们老的很快
- HDOJ 题目分类
- 最后的颓废
- 写一些不属于自己的文字
- C++学习【原创】Orders(nex…
- ACM  next_permutation函数