#include <iostream>
#include <string>
/*
Translate number to string presentation: 1->a, 27->aa, 28->ab
http://www.leetcode.com/2010/10/amazon-bar-raiser-interview-question.html
*/
std::string num_to_string(int n)
{
std::string res = "";
while (n != 0)
{
char cur_char = (char)((n % 26) + 'a' - 1);
std::string cur_str(1, cur_char);
n /= 26;
res = cur_str + res;
}
return res;
}
int main()
{
std::string res = num_to_string(1);
return 0;
}
Excel Sheet Row Numbers
最新推荐文章于 2024-06-30 13:43:42 发布