All hexadecimal conversions in hexadecimal notation !!!! Fast, simple operation, java, hexadecimal java
Import java. util. extends; public class P2031 {public static void main (String [] args) {Using SC = new using (System. in); char chs [] = {'0', '1', '2', '3', '4', '5', '6 ', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F '}; // The maximum number of all hexadecimal while (SC. hasNext () {int n = SC. nextInt (); // The number of int r = SC to be converted. nextInt (); // The hexadecimal boolean isNegative to be converted = false; // determines whether a negative number exists. if (n <0) {n =-n; isNegative = true ;} string str = ""; while (n/r> 0) {str = ch S [n % r] + str; // Add the calculated result to the front n = n/r;} if (n % r! = 0) {// if division is not allowed, run this operation and add the remainder to the beginning of the result str = chs [n % r] + str;} if (isNegative) {// run the command only when the plural number exists. Add the negative str = "-" + str;} System to the result. out. println (str );}}}