LeetCode题解——Excel Sheet Column Title
来源:互联网 发布:数据化人生 编辑:程序博客网 时间:2024/05/19 21:44
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 -> AA28 -> AB
class Solution {public: string convertToTitle(int n) {//26进制 /* string ans; int i=n/26,j=n%26; if(i==0 ){ ans+='A'+j-1; return ans; }if(i==1 && j==0){ ans+='Z'; return ans;} if(j==0){ ans+=convertToTitle(i-1); ans+='Z'; return ans; } ans+=convertToTitle(i); ans+='A'+ j-1; return ans;*/ return n == 0 ? "" : convertToTitle((n - 1) / 26) + (char) ((n - 1) % 26 + 'A');//可以将上面的一段代码精简为一句话 }};
0 0
- LeetCode题解——Excel Sheet Column Title
- LeetCode题解:excel-sheet-column-title
- LeetCode题解:Excel Sheet Column Title
- LeetCode 题解(215) : Excel Sheet Column Title
- Leetcode题解 168. Excel Sheet Column Title
- LeetCode—Excel Sheet Column Title
- leetcode——168——Excel Sheet Column Title
- Leetcode: Excel Sheet Column Title
- [LeetCode]Excel Sheet Column Title
- leetcode:Excel Sheet Column Title
- [LeetCode]Excel Sheet Column Title
- [LeetCode] Excel Sheet Column Title
- [leetcode]Excel Sheet Column Title
- LeetCode--Excel Sheet Column Title
- Leetcode: Excel Sheet Column Title
- 【Leetcode】Excel Sheet Column Title
- [LeetCode] Excel Sheet Column Title
- 【Leetcode】Excel sheet Column title
- Linux - 文件权限
- uva 816Abbott's Revenge (走迷宫BFS)
- 根据两点经纬度计算距离
- 经常吹空调皮肤是不是会变黑
- thinkpad E430拆装与升级
- LeetCode题解——Excel Sheet Column Title
- js倒计时代码 支持同一页面多个倒计时代码(转)
- POJ 3352 Road Construction(边双连通分量)
- uva11297 二维线段树
- shopNC分类,递归方式查询层级显示
- LeetCode-Product of Array Except Self
- ViewPager取消左右滑动切换功能
- 关于asp.net网址出现乱码问题的解决方法
- hdu4044GeoDefense 树形dp+分组背包