Basic practice hex-to-decimal time limit: 1.0s memory limit: 512.0MBThe problem description enters a positive hexadecimal number string that does not exceed 8 bits from the keyboard, converting it to a positive decimal number after the output.
Note: 10~15 in hexadecimal numbers are denoted by uppercase letters A, B, C, D, E, F, respectively. Sample input FFFF sample output 65535
Seconds to cut the fruit ... (don't know whether to be happy or sad)
Import Java.io.*;import java.util.*;p ublic class main{public static void Main (string[] args) {//TODO auto-generated Metho D stubscanner input = new Scanner (system.in); String str = Input.nextline (), char c[] = Str.tochararray (), Long sum = 0;for (int i = 0; i < c.length; i++) {if (c[i) = ' 0 ' && c[i] <= ' 9 ') {sum + = (c[i]-' 0 ') * MATH.POW (C.length-i-1);} else{sum + = (c[i]-' A ' +) * M Ath.pow (C.length-i-1);}} SYSTEM.OUT.PRINTLN (sum);}}
Blue Bridge Cup-basic exercise-16 Decimal to Binary