标签:
题目链接: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; } };
leetcode-Excel Sheet Column Title
标签:
原文地址:http://www.cnblogs.com/shirley-ict/p/5539421.html