就是个26进制

 

class Solution {
public:
    string convertToTitle(int n) {
        string ans = "";
        while(n) {
            ans = string(1, ((n - 1) % 26 + 'A')) + ans;
            n = (n - 1) / 26;
        }
        return ans;
    }
};

 

相关文章:

  • 2021-12-05
  • 2022-12-23
  • 2022-12-23
  • 2021-08-20
  • 2021-11-07
  • 2022-12-23
猜你喜欢
  • 2021-07-05
  • 2021-08-08
  • 2021-11-20
  • 2022-02-10
  • 2022-03-05
相关资源
相似解决方案