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

posted @ 2018-05-11 09:50  sysu_kww  阅读(115)  评论(0编辑  收藏  举报