#include<string>
using namespace std;
class Solution {
public:
   string convertToTitle(int n) {
         string res;
         if(n<=0) return "";
       while(n)
    {
      res+=(n-1)%26+'A';   //[n-1]这里一定要想明白了,注意头尾两个数据的验证
      n=(n-1)/26;
    }
    reverse(res.begin(),res.end());
    return res;
  }
};

数字转表格标题 Excel Sheet Column Title的更多相关文章

  1. 【leetcode】Excel Sheet Column Title & Excel Sheet Column Number

    题目描述: Excel Sheet Column Title Given a positive integer, return its corresponding column title as ap ...

  2. Excel Sheet Column Title & Excel Sheet Column Number

    Excel Sheet Column Title Given a positive integer, return its corresponding column title as appear i ...

  3. 2016.5.19——Excel Sheet Column Title

    Excel Sheet Column Title 本题收获: 1.由int型转换为整型(string),如何转化, res = 'A'+(n-1)%26和之前由A-z转化为十进制相反,res = s[ ...

  4. Leetcode Excel Sheet Column Number (C++) && Excel Sheet Column Title ( Python)

    Given a column title as appear in an Excel sheet, return its corresponding column number. For exampl ...

  5. 【leetcode】Excel Sheet Column Title

    Excel Sheet Column Title Given a non-zero positive integer, return its corresponding column title as ...

  6. 168. Excel Sheet Column Title

    Excel Sheet Column Title Given a positive integer, return its corresponding column title as appear i ...

  7. Excel Sheet Column Title&&Excel Sheet Column Number

    Excel Sheet Column Title Given a positive integer, return its corresponding column title as appear i ...

  8. LeetCode 168. Excel表列名称(Excel Sheet Column Title)

    168. Excel表列名称 168. Excel Sheet Column Title 题目描述 给定一个正整数,返回它在 Excel 表中相对应的列名称. LeetCode168. Excel S ...

  9. LeetCode_168. Excel Sheet Column Title

    168. Excel Sheet Column Title Easy Given a positive integer, return its corresponding column title a ...

随机推荐

  1. Android 自定义控件之app标题栏的封装

    在app的开发中,每一个页面都有上面的标题栏,总不能在开发的过程中没个界面都写一个标题栏的布局,所以为了开发的方便,将该标题栏进行的封装,以后在实际的开发工作中,也可以将该封装好的标题栏控件直接拿来使 ...

  2. UISegment属性

    1.segmentedControlStyle 设置segment的显示样式. typedefNS_ENUM(NSInteger, UISegmentedControlStyle) { UISegme ...

  3. LuaExpat笔记

    xml xml是一种格式化数据交换语言, 适用于在网络上不同应用会话. http://www.xml.com/pub/a/98/10/guide0.html exPat 一种C语言实现的 xml 文档 ...

  4. 如何修改DBSNMP和SYSMAN用户的密码

    SYSMAN和DBSNMP用户密码过期后OEM无法使用,并报以下错误: SYSMAN用户的密码被加密后存放在不同的地方,这样database control(OMS和agent)可以不用每次访问数据库 ...

  5. [转]Entity Framework技术导游系列开篇与热身

    学习Entity Framework技术期间查阅的优秀文章,出于以后方便查阅的缘故,转载至Blog,可查阅原文:http://blog.csdn.net/bitfan/article/details/ ...

  6. Java基础之创建窗口——向窗口中添加菜单(Sketcher)

    控制台程序. JMenuBar对象表示放在窗口顶部的菜单栏.可以为JMenuBar对象添加JMenu或JMenuItem对象,它们都显示在菜单栏上.JMenu对象是带有标签的菜单,单击就可以显示一列菜 ...

  7. mysql:innodb monitor(show engine innodb status)探秘

    在旧的版本里面是show innodb status命令,新版本后改动了一些:show engine innodb status; 我们最熟悉的,应当就是show innodb status命令,可以 ...

  8. IntelliJ IDEA 常用设置讲解3

    IntelliJ IDEA 有很多人性化的设置我们必须单独拿出来讲解,也因为这些人性化的设置让我们这些 IntelliJ IDEA 死忠粉更加死心塌地使用它和分享它. 常用设置 如上图 Gif 所示, ...

  9. J2EE MyBatis使用

    MyBatis 本是apache的一个开源项目iBatis, 2010年这个项目由apache software foundation 迁移到了google code,并且改名为MyBatis .20 ...

  10. Leetcode: Range Sum Query - Mutable && Summary: Segment Tree

    Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive ...