给定一个正整数,返回它在Excel表中相对应的列名称。
示例:
1 -> A
2 -> B
3 -> C
...
26 -> Z
27 -> AA
28 -> AB
详见:https://leetcode.com/problems/excel-sheet-column-title/description/
class Solution { public: string convertToTitle(int n) { string res=""; while(n) { res=char((n-1)%26+‘A‘)+res; n=(n-1)/26; } return res; } };
参考:https://www.cnblogs.com/ganganloveu/p/4175848.html
原文地址:https://www.cnblogs.com/xidian2014/p/8729437.html
时间: 2024-08-12 04:38:43