leetcode:数学:Excel Sheet Column Title(168)

原创 2016年08月30日 15:13:37

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 

class Solution {
public:
    string convertToTitle(int n) {
        string ret = "";
        --n;
        while (n >= 0) {
            ret += (char)('A' + n % 26);
            n /= 26;
            --n;
        }
        reverse(ret.begin(), ret.end());
        return ret;
    }
};
版权声明:本文为博主原创文章,未经博主允许不得转载。

相关文章推荐

[LeetCode]--168. Excel Sheet Column Title

Given a positive integer, return its corresponding column title as appear in an Excel sheet.For exam...

LeetCode 168. Excel Sheet Column Title 解题报告

题目描述: 168. Excel Sheet Column Title   Given a positive integer, return its corresponding ...

[LeetCode]168.Excel Sheet Column Title

【题目】 Given a positive integer, return its corresponding column title as appear in an Excel sheet. ...

<LeetCode OJ> 171 / 168 Excel Sheet Column Number & Title

171. Excel Sheet Column Number My Submissions Question Total Accepted: 58671 Total Submissions: ...

LeetCode 168 Excel Sheet Column Title(Excel的列向表标题)

翻译给定一个正整数,返回它作为出现在Excel表中的正确列向标题。例如: 1 -> A 2 -> B 3 -> C ... 26 -> Z 27 -> ...
  • NoMasp
  • NoMasp
  • 2016年01月11日 19:57
  • 3356

leetcode 之Excel Sheet Column Title

Total Accepted: 9173 Total Submissions: 52899 Given a positive integer, return its corres...

【LeetCode】Excel Sheet Column Title

Excel Sheet Column Title 问题描述见链接。 在这个问题中,其实设计的是类似于二进制、十六进制的一种进位方式,可以认为是二十六进制,然而难点在于A-Z中没有0这个数,也...
  • cczz598
  • cczz598
  • 2015年03月15日 21:21
  • 245

[C++]LeetCode: 57 Excel Sheet Column Title

题目: Given a positive integer, return its corresponding column title as appear in an Excel sheet. F...

LeetCode: Excel Sheet Column Title

题目:Given a positive integer, return its corresponding column title as appear in an Excel sheet.For e...

关于LeetCode中Excel Sheet Column Title一题的理解

题目如下: Given a positive integer, return its corresponding column title as appear in an Excel sheet....
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:leetcode:数学:Excel Sheet Column Title(168)
举报原因:
原因补充:

(最多只允许输入30个字)