题目:
Given a positive integer, return its corresponding column title as appear in an Excel sheet.
For example:
1 -> A 2 -> B 3 -> C ... 26 -> Z 27 -> AA 28 -> AB代码:
string convertToTitle(int n) {
string str;
int b = 0;
int c = 0;
while(n>0)
{
b = n%26;
n = n/26;
if(b== 0)
{
b = 26;
--n;
}
str.insert(str.begin(),(char)(b+64));
}
return str;
}
相当于将数转成"27位"数,再见每一个位转成ascII表对应的大写字母