#include<string>
using namespace std;
class Solution {
public:
   string convertToTitle(int n) {
         string res;
         if(n<=0) return "";
       while(n)
    {
      res+=(n-1)%26+'A';   //[n-1]这里一定要想明白了,注意头尾两个数据的验证
      n=(n-1)/26;
    }
    reverse(res.begin(),res.end());
    return res;
  }
};

相关文章:

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