zl程序教程

您现在的位置是:首页 >  其他

当前栏目

[LeetCode] Excel Sheet Column Number

LeetCodeExcel number Column sheet
2023-09-14 09:01:04 时间
Given a column title as appear in an Excel sheet, return its corresponding column number. For example: A - 1 B - 2 C - g
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 
实现代码:
/*****************************************************************************

 * @COPYRIGHT NOTICE

 * @Copyright (c) 2015, 楚兴

 * @All rights reserved

 * @Version : 1.0

 * @Author : 楚兴

 * @Date : 2015/2/6 14:29

 * @Status : Accepted

 * @Runtime : 15 ms

*****************************************************************************/

#include iostream 

#include vector 

#include algorithm 

using namespace std;

class Solution {

public:

 int titleToNumber(string s) {

 int column = 0;

 for (int i = 0; i s.size(); i++)

 if (s[i] = A s[i] = Z)

 column = column * 26 + s[i] - A + 1;

 return column;

int main()

 Solution s;

 int a = s.titleToNumber("AA");

 cout a endl;

 system("pause");

}




table合并单元格colspan和rowspan colspan和rowspan这两个属性用于创建特殊的表格。 colspan是“column span(跨列)”的缩写。colspan属性用在td标签中,用来指定单元格横向跨越的列数: 在浏览器中将显示如下:
Excel的Range对象(C#) 原文:Excel的Range对象(C#) Range 对象是 Excel 应用程序中最经常使用的对象;在操作 Excel 内的任何区域之前,都需要将其表示为一个 Range 对象,然后使用该 Range 对象的方法和属性。
Given a column title as appear in an Excel sheet, return its corresponding column number. For example: A - 1 B - 2 C - 3
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