leetcode-Excel Sheet Column Title
题目链接:https://leetcode.com/problems/excel-sheet-column-title/
代码如下:
class Solution { public: string convertToTitle(int n) { string ans(""); while(n > 0) { int digit = n % 26; if(digit == 0) { digit = 26; } ans = (char)('A' + digit - 1) + ans; n = (n - 1) / 26; } return ans; } };