本文主要是介绍LeetCode *** 168. Excel Sheet Column Title,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
题目:
Given a positive integer, return its corresponding column title as appear in an Excel sheet.
For example:
1 -> A2 -> B3 -> C...26 -> Z27 -> AA28 -> AB
代码:
class Solution {
public:string convertToTitle(int n) {string s="",t="";while(n){n=n-1;s+='A'+n%26;n/=26;}int len=s.length();for(int i=len-1;i>=0;--i){t+=s[i];}return t;}
};
这篇关于LeetCode *** 168. Excel Sheet Column Title的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!