【leetcode】Excel Sheet Column Title
Excel Sheet Column Title
Given a non-zero 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
类似于数制转换,只不过1对应A,而不是0对应A
class Solution {
public:
string convertToTitle(int n) {
string res="";
while(n>)
{
int tmp=(n-)%;
res.push_back('A'+tmp);
n=(n-)/;
}
string result(res.rbegin(),res.rend());
return result;
}
};
【leetcode】Excel Sheet Column Title的更多相关文章
- 【leetcode】Excel Sheet Column Title & Excel Sheet Column Number
题目描述: Excel Sheet Column Title Given a positive integer, return its corresponding column title as ap ...
- 【leetcode】Excel Sheet Column Title & Excel Sheet Column Number (easy)
Given a positive integer, return its corresponding column title as appear in an Excel sheet. For exa ...
- 【leetcode】Excel Sheet Column Number
Excel Sheet Column Number Related to question Excel Sheet Column Title Given a column title as appea ...
- 【LeetCode】Excel Sheet Column Number(Excel表列序号)
这道题是LeetCode里的第171道题. 题目描述: 给定一个Excel表格中的列名称,返回其相应的列序号. 例如, A -> 1 B -> 2 C -> 3 ... Z -> ...
- [LeetCode] 168. Excel Sheet Column Title 求Excel表列名称
Given a positive integer, return its corresponding column title as appear in an Excel sheet. For exa ...
- leetcode 168. Excel Sheet Column Title 171 Excel Sheet Column Number
题目 //像10进制一样进行 转换 只是要从0开始记录 class Solution { public: string convertToTitle(int n) { char a; string ...
- LeetCode 168. Excel Sheet Column Title (Excel 表格列名称)
Given a positive integer, return its corresponding column title as appear in an Excel sheet. For exa ...
- LeetCode 168. Excel Sheet Column Title
Given a positive integer, return its corresponding column title as appear in an Excel sheet. -> A ...
- ✡ leetcode 168. Excel Sheet Column Title 26进制数字 --------- java
Given a positive integer, return its corresponding column title as appear in an Excel sheet. For exa ...
随机推荐
- linux 下 zip unzip压缩与解压
注:*压缩成限.zip格式文件 常用解压缩: [root@mysql test]# unzip -o test.zip -d tmp/ 将压缩文件test.zip在指定目录tmp下解压缩,如果已有相同 ...
- 404. Sum of Left Leaves
Find the sum of all left leaves in a given binary tree. 左树的值(9+15=24) /** * Definition for a binary ...
- Android Studio-设置放大代码编辑区
原有的快捷键是ctrl+shift+F12,现在我修改成了Ctrl+M.
- CF459C Pashmak and Buses (构造d位k进制数
C - Pashmak and Buses Codeforces Round #261 (Div. 2) C. Pashmak and Buses time limit per test 1 seco ...
- GOF业务场景的设计模式-----责任链模式
定义:使多个对象都有机会处理请求,从而避免了请求的发送者和接收者之间的耦合关系.将这些对象连成一条链,并沿着这条链传递该请求,直到有对象处理它为止. 首先来看一段代码: public void tes ...
- 基础知识系列☞C#中数组Array、ArrayList和List三者的区别
数组() #region 数组 //初始化方式_0:先声明再赋值 ]; weekDays_0[] = "Sun"; weekDays_0[] = "Mon"; ...
- uml面向对象建模基础总结
uml九种图,其中的细节不说了.在后面的具体使用中提到这九种图. 建模流程: 1.分析需求. 2.通过分析名词,发现类,使用到类图. 3.建立用例模型,通过参与者分析用例,使用到用例图. 4.为用例建 ...
- QT文件读写
/* //文件读取 QFile f("c:\\t.txt"); if(!f.open(QIODevice::WriteOnly | QIODevice::Text)) { qDeb ...
- Apache开发模块
输入perl Configure.pl 安装目录...\apache2.2 “httpd.exe” 生成apxs命令, apache2.2下build目录中的config_vars.mk文件 将CC ...
- git之remote branch controller(远程分支控制)
1.创建本地分支 git branch //查看远程分支 git checkout -b branch_name //创建远程分支 在查看分支git branch 2.将分支提交到远程仓库 此时远程 ...