# 十进制转十六进制

import java.util.Scanner;

/**
* Main
*
* @author 小朝
* @date 2020/3/2
*/
public class Main {

public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int x = scanner.nextInt();
int [] result = new int [20];
int divisor = 1;
// 记录结果长度
int len = 0;
for(int i=0;divisor!=0;i++){
len ++;
// 余数
result[i] = x%16;
// 除数
divisor = x/16;
x = divisor;
}
for(int i =len-1;i>-1;i--){
if(result[i] == 10){
System.out.print("A");
}else if(result[i] == 11){
System.out.print("B");
}else if(result[i] == 12){
System.out.print("C");
}else if(result[i] == 13){
System.out.print("D");
}else if(result[i] == 14){
System.out.print("E");
}else if(result[i] == 15){
System.out.print("F");
}else {
System.out.print(result[i]);
}
}
}
}


# 十六进制转十进制

import java.util.Scanner;

/**
* Main
*
* @author 邱朝
* @date 2020/3/2
*/
public class Main {

public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String x = scanner.next();
long result = 0;
String[] strings = x.split("");
for(int i=0;i<strings.length;i++){
// 记录每个数的值
int temp=0;
if("A".equals(strings[i])){
temp = 10;
}else if("B".equals(strings[i])){
temp = 11;
}else if("C".equals(strings[i])){
temp = 12;
}else if("D".equals(strings[i])){
temp = 13;
}else if("E".equals(strings[i])){
temp = 14;
}else if("F".equals(strings[i])){
temp = 15;
}else {
temp = Integer.parseInt(strings[i]);
}
result += temp*Math.pow(16,strings.length-1-i);
}
System.out.println(result);
}
}


# 十六进制转八进制

import java.util.Scanner;

/**
* Main
*
* @author 小朝
* @date 2020/3/2
*/
public class Main {

public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
// array存储n个八进制数的结果
int [][] array = new int[n][];
String[] strs =new String[n];
for(int i =0;i<n;i++){
// 转十进制
strs[i] = scanner.next();
// 记录十进制的结果
long result = 0;
String[] strings = strs[i].split("");
for(int j=0;j<strings.length;j++){
// 记录每个数的值
int temp=0;
if("A".equals(strings[j])){
temp = 10;
}else if("B".equals(strings[j])){
temp = 11;
}else if("C".equals(strings[j])){
temp = 12;
}else if("D".equals(strings[j])){
temp = 13;
}else if("E".equals(strings[j])){
temp = 14;
}else if("F".equals(strings[j])){
temp = 15;
}else {
temp = Integer.parseInt(strings[j]);
}
result += temp*Math.pow(16,strings.length-1-j);
}
// 转八进制
int [] newResult = new int [10000];
int divisor = 1;
int len = 0;
int m = (int)result;
for(int k=0;divisor!=0;k++){
len ++;
// 余数
newResult[k] = m%8;
// 除数
divisor = m/8;
m = divisor;
}
int[] temp = new int[len];
for(int z =len-1,a=0;z>-1;z--,a++){
temp[a] =newResult[z];
}
// 将八进制的结果存入最终的二维数组
array[i] = temp;
}
for(int i=0;i<array.length;i++){
for(int j=0;j<array[i].length;j++){
System.out.print(array[i][j]);
}
System.out.println();
}
}
}


11-20 482

04-08 2516
03-04 5万+
06-16 3万+
12-24 3847
04-23 3万+
01-15 4884
06-03 9195
10-23 586
03-18 449
07-23 3291
03-04 759
11-01 4万+