- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProblem168.java
More file actions
Latest commit
36 lines (28 loc) · 729 Bytes
/
Copy pathProblem168.java
File metadata and controls
36 lines (28 loc) · 729 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
classProblem168 {
publicstaticvoidmain(String[] args) {
System.out.println(convertToTitle(28));
System.out.println(convertToTitle(701));
System.out.println(convertToTitle(1023));
System.out.println(convertToTitle(7772));
System.out.println(convertToTitle(52));
Objecto = null;
longvalue = (long) o;
System.out.println(value);
// 703 AAA 703/26 = 27/26 = 1 ... 1
// 702 ZZ 702/26 = 27/26 = 1
// 701 ZY 701/26 = 26/26 = 0
// 26 0Z
// 27 AA
// 28 AB
// 701 ZY
// 702 ZZ
}
publicstaticStringconvertToTitle(intn) {
Stringres = "";
while (n > 0) {
res = (char)('A' + --n % 26) + res;
n = n / 26;
}
returnres;
}
}