## codewars064 - Get the Excel column title! 原

圣洁之子

### Instructions

``````https://www.codewars.com/kata/get-the-excel-column-title/train/java
``````

### Solution:

``````import java.util.Stack;
public class GetExcelColumnTitle {
private static final	String digits = "0ABCDEFGHIJKLMNOPQRSTUVWXYZ";
public static String getColumnTitle(int num) {

final int base = 26;
if(num <= 0){
throw new IllegalArgumentException();
}
StringBuilder sb = new StringBuilder();

Stack<Character> s = new Stack<Character>();
while(num != 0){
if(num % base != 0){
s.push(digits.charAt(num % base));
num = num / base;
}else{
s.push(digits.charAt(base));
num = num / base - 1;
}
}
while(!s.isEmpty()){
sb.append(s.pop());
}
return sb.toString();

}
}
``````

### Sample Tests:

``````https://www.codewars.com/kata/get-the-excel-column-title/train/java
``````

### Ref

``````http://ideasforjava.iteye.com/blog/636685
``````

### 圣洁之子

leetcode 171: Excel Sheet Column Number

Related to question Excel Sheet Column Title Given a column title as appear in an Excel sheet, return its corresponding column number. For example: A -> 1 B -> 2 C -> 3 ... Z ->......

2015/02/03
0
0

2017/07/04
0
0
Excel Sheet Column Number(leetcode171)

Given a column title as appear in an Excel sheet, return its corresponding column number. For example: A -> 1 Example 1: Input: "A"Output: 1 Example 2: Input: "AB"Output: 28 Exa......

woshixin
2018/11/12
0
0
LeetCode - Easy - Excel Sheet Column Number

Given a column title as appear in an Excel sheet, return its corresponding column number. For example: thinking: 进制之间的装换 solution: public class ExcelSheetColumnNumber {p......

2018/03/28
0
0
Excell列标题

2016/12/26
2
0

linux-tao

1
0

4
0

2
0
cocoapods 用法

cocoapods install pod install 更新本地已经install的仓库 更新所有的仓库 pod update --verbose --no-repo-update 更新制定的仓库 pod update ** --verbose --no-repo-update...

HOrange

3
0
linux下socket编程实现一个服务器连接多个客户端

shzwork

3
0