168. Excel Sheet Column Title
2016-05-14 14:52
417 查看
Problem
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
Solution
class Solution { public: string convertToTitle(int n) { if(n == 0) return ""; string ret = ""; while(n) { ret+=(--n)%26+'A'; n/=26; } reverse(ret.begin(),ret.end()); return ret; } };
相关文章推荐
- ztr loves lucky numbers(STL)
- Android实现登录系统(一)--QQ登录
- 线性结构总结(1)-基于链表的实现
- 3. Longest Substring Without Repeating Characters
- 电子常识
- 电子常识
- assert与if的区别
- Activiti源码分析
- 第二章 Python简介
- 2. Add Two Numbers
- java24为什么用抽象类
- 教你怎么半天搞定Docker
- MQ 概述
- Designing for Multi-Window
- 使用自定义模板为Myeclipse添加新建Filter的功能
- 笔试面试题8--内联函数和宏的区别
- Form表单的操作
- 将本地代码push到GitLab空仓库
- Tomcat安装实战
- VMware下ubuntu扩展磁盘空间