168. Excel Sheet Column Title
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
其实类似26进制数
class Solution { public: string convertToTitle(int n) { string s = ""; while (n > 0) { int y = --n%26 ; n /= 26; s = char(y + 'A') + s; } return s; } };
原文地址:http://www.cnblogs.com/pk28/
与有肝胆人共事,从无字句处读书。
欢迎关注公众号:
欢迎关注公众号: