首页 > 其他分享 >LeetCode 168. Excel Sheet Column Title

LeetCode 168. Excel Sheet Column Title

时间:2022-10-18 14:08:09浏览次数:69  
标签:26 Sheet string Title Column res int while ans

​题目​

class Solution {
public:
string convertToTitle(int n) {


string ans="";


while(n)
{
int x = (n-1) % 26;

ans += ('A'+ x );

n = (n-1) / 26;
}

string res="";

for(int i=ans.length()-1;i>=0;i--)
{
res += ans[i];
}

return res;

}
};



标签:26,Sheet,string,Title,Column,res,int,while,ans
From: https://blog.51cto.com/u_15834522/5766253

相关文章