题解 | #进制转换#
进制转换
https://www.nowcoder.com/practice/8f3df50d2b9043208c5eed283d1d4da6
<?php fscanf(STDIN, "%s", $str); $map = [ '0' => 0, '1' => 1, '2' => 2, '3' => 3, '4' => 4, '5' => 5, '6' => 6, '7' => 7, '8' => 8, '9' => 9, 'A' => 10, 'B' => 11, 'C' => 12, 'D' => 13, 'E' => 14, 'F' => 15 ]; $num = 0; $basic = 16; for($i = 2; $i < strlen($str); $i++){ $char = $str[$i]; $value = $map[$char]; $num = $num * 16 + $value; } echo $num;#2022牛客时光#