标签:
题目链接:https://oj.leetcode.com/problems/excel-sheet-column-number/
给出excel表格中的列号(A,AA,AB),返回数字表示的列号
For example:
A -> 1 B -> 2 C -> 3 ... Z -> 26 AA -> 27 AB -> 28
1 string convertToTitle(int n) { 2 string ret=""; 3 if(n<=0)return ret; 4 5 do{ 6 n--; 7 int mod=n%26; 8 n=n/26; 9 ret=(char)(mod+‘A‘)+ret; 10 }while(n); 11 12 return ret; 13 }
标签:
原文地址:http://www.cnblogs.com/li-xingtao/p/4226153.html