The answer is as follows:
Void convert () {Map <int, string> maps; maps [0] = "0"; maps [1] = "1"; maps [2] = "2 "; maps [3] = "3"; maps [4] = "4"; maps [5] = "5"; maps [6] = "6 "; maps [7] = "7"; maps [8] = "8"; maps [9] = "9"; for (INT I = 10, j = 65; I <36, j <91; I ++, J ++) {maps [I] = (char) J ;}cout <"Enter the number to be converted: "; stack <int> stack1; int num; int Lis; int RS; CIN> num; cout <" Enter the number of destination hexadecimal values to be converted :"; cin> Lis; while (num! = 0) {rs = num % Lis; num = num/LIS; stack1.push (RS);} string buffer; For (int K = stack1.size (); k> 0; k --) {int M = stack1.top (); buffer + = maps [m]; stack1.pop ();} switch (buffer. size () {Case 3: Buffer = "0" + buffer; break; Case 2: Buffer = "00" + buffer; break; Case 1: buffer = "000" + buffer; break; Case 0: Buffer = "0000"; break; default: break;} cout <buffer <Endl ;}
Please point out any errors or good suggestions!
Decimal and N-base conversion (decimal to 36hexadecimal)