题目
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;
}
};
题目
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;
}
};