public static void main(String[] args) { String hex = toHex(12500); System.out.println(hex); if (hex.equalsIgnoreCase("30D4")) { System.out.println("测试通过"); } else { System.out.println("测试失败"); }}static String toHex(int n) { Stack stake=new Stack<Character>(); do { stake.push(Integer.toHexString(n%16)); n=n/16; }while (n!=0); String s=""; while (!stake.isEmpty()){ s=s+stake.pop(); } return s;}
Sign in to make a reply
笑川之主