代码:
class Solution {
public:
string convertToTitle(int n) {
string s;
map<int, char> m;
for(int i = 0; i < 26 ; i ++) {
m[i] = 'A'+i;
}
while(1) {
s.insert(s.begin(), m[(n-1)%26]);
if(n == 26) return s;
if(n%26 == 0) n--;
n = n / 26;
if(n == 0) return s;
}
}
};