62,628
社区成员
发帖
与我相关
我的任务
分享package test;
import java.util.HashMap;
import java.util.Map;
import java.util.Stack;
public class SixteenScale {
private static Stack<String> sk = new Stack<String>();
static Map<Integer , String> map = new HashMap<Integer,String>();
public static void main(String[] args) {
int i = 28;//被转换数
initMap();
int last = i%16;
sk.push(map.get(last));
int result = (int) Math.floor(i/16.0);
while(result!=0){
last = result%16;
sk.push(map.get(last));
result = (int) Math.floor(result/16.0);
}
System.out.print("转换后的数为:");
while(!sk.empty()){
System.out.print(sk.pop());
}
}
private static void initMap() {
map.put(1, "1");
map.put(2, "2");
map.put(3, "3");
map.put(4, "4");
map.put(5, "5");
map.put(6, "6");
map.put(7, "7");
map.put(8, "8");
map.put(9, "9");
map.put(10, "A");
map.put(11, "B");
map.put(12, "C");
map.put(13, "D");
map.put(14, "E");
map.put(15, "F");
}
}
这是,什么鬼