Excel Sheet Column Number(STRING-TYPE CONVERTION)
QUESTION
Related to question Excel Sheet Column Title
Given a column title as appear in an Excel sheet, return its corresponding column number.
For example:
A -> 1
B -> 2
C -> 3
...
Z -> 26
AA -> 27
AB -> 28
FIRST TRY
string与数字的转换要借助char
class Solution {
public:
int titleToNumber(string s) {
int ret = ;
char ch;
for(int i = ; i < s.length(); i++)
{
ch = s[i]; //string to char
ret = ret* + ch - 'A' + ;
}
return ret;
}
};
Excel Sheet Column Number(STRING-TYPE CONVERTION)的更多相关文章
- Excel Sheet Column Title (STRING - TYPE CONVERTION)
QUESTION Given a positive integer, return its corresponding column title as appear in an Excel sheet ...
- 【leetcode】Excel Sheet Column Title & Excel Sheet Column Number
题目描述: Excel Sheet Column Title Given a positive integer, return its corresponding column title as ap ...
- Excel Sheet Column Title & Excel Sheet Column Number
Excel Sheet Column Title Given a positive integer, return its corresponding column title as appear i ...
- 【leetcode】Excel Sheet Column Number
Excel Sheet Column Number Related to question Excel Sheet Column Title Given a column title as appea ...
- 【LeetCode】168 & 171- Excel Sheet Column Title & Excel Sheet Column Number
168 - Excel Sheet Column Title Given a positive integer, return its corresponding column title as ap ...
- 171. Excel Sheet Column Number(C++)
171. Excel Sheet Column Number Related to question Excel Sheet Column Title Given a column title as ...
- LeetCode Javascript实现 100. Same Tree 171. Excel Sheet Column Number
100. Same Tree /** * Definition for a binary tree node. * function TreeNode(val) { * this.val = val; ...
- 2016.5.18——Excel Sheet Column Number
Excel Sheet Column Number 本题收获: 1.对于字符串中字母转为ASIIC码:string s ;res = s[i]-'A'; 这个res就是数字s[i]-'A'是对ASII ...
- leetcode 168. Excel Sheet Column Title 171 Excel Sheet Column Number
题目 //像10进制一样进行 转换 只是要从0开始记录 class Solution { public: string convertToTitle(int n) { char a; string ...
- Excel Sheet Column Title&&Excel Sheet Column Number
Excel Sheet Column Title Given a positive integer, return its corresponding column title as appear i ...
随机推荐
- [转]NSIS:常量大全
原文链接 http://www.flighty.cn/html/bushu/20140915_251.html ;轻狂志www.flighty.cn ;运行后会在桌面生成NSIS常量大全.txt文件 ...
- 1036 Boys vs Girls (25 分)
1036 Boys vs Girls (25 分) This time you are asked to tell the difference between the lowest grade of ...
- 深入理解HTTP协议之POST方法——ajax实例
作者:吴俊杰 性别:男 邮箱:sshroot@126.com 文章类型:原创 博客:http://www.cnblogs.com/voiphudong/ 一.说明http协议其实是一个相对比较简单的应 ...
- 初步认识AutoMapper
AutoMapper 初步认识AutoMapper 前言 手动映射 使用AutoMapper 创建映射 Conventions 映射到一个已存在的实例对象 前言 通常在一个应用程序中,我们开发 ...
- Lunce编程模型
问题的场景: 解决方案:都是来自于科技论文 ============================================================================== ...
- Python print函数参数详解
官方文档 print(…) print(value, …, sep=’ ‘, end=’\n’, file=sys.stdout, flush=False) Prints the valu ...
- treap Python实现
# coding=utf-8 # treap(树堆)Python实现 import random def preorder_tree_walk(node): if node: print node.k ...
- Visual Studio自动添加头部注释
VS2013 自动添加头部注释 1.找到VS2013的安装目录 下文以安装目录 C:\Program Files (x86)\Microsoft Visual Studio 12.0 为例 2.修改C ...
- [Flutter] Android沉侵式标题栏顶部叠加层去除
可能你的app是这样: 框起来部分和标题栏颜色并不一致. 调用下面的代码可以变成一样. import 'package:flutter/services.dart'; static SystemUiO ...
- canvas学习笔记、小函数整理
http://bbs.csdn.net/topics/391493648 canvas实例分享 2016-3-16 http://bbs.csdn.net/topics/390582151 html5 ...