——————————————————————————————————————————————————————
分析:
使用Java类库的API;
输入十六进制字符串->用Long.parseLong()->解析成long型变量->输出
——————————————————————————————————————————————————————
代码:
import java.util.Scanner; public class Main { public static void main(String[] args) { // TODO Auto-generated method stub Scanner cin = new Scanner(System.in); while(cin.hasNext()) { String hex_num = cin.nextLine(); long dec_num = Long.parseLong(hex_num, 16); System.out.println(dec_num); } cin.close(); } }
原文地址:http://blog.csdn.net/feixia586/article/details/26206605