leetcode-Excel Sheet Column Title
Posted Shirley_ICT
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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; } };
以上是关于leetcode-Excel Sheet Column Title的主要内容,如果未能解决你的问题,请参考以下文章