168. Excel Sheet Column Title

Posted sysu_kww

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了168. Excel Sheet Column Title相关的知识,希望对你有一定的参考价值。

该题目是实际上是要将10进制转换为26进制。代码如下:

 

 1 class Solution {
 2     public String convertToTitle(int n) {
 3         String res = new String();
 4         
 5         while( n != 0 ){
 6             int r = (n-1)%26;
 7             n = (n-1) / 26;
 8             res = ((char)(\'A\' + r)) + res;
 9         }
10         
11         return res;
12     }
13 }

 

 

END

以上是关于168. Excel Sheet Column Title的主要内容,如果未能解决你的问题,请参考以下文章