Last time I saw a minimally invasive interview question on the 9CBS forum, I saw it, and the data structure has been lost for more than two years. Now I suddenly see such a topic, suddenly there is a little nostalgic feeling. So it is a bit itchy, decided to do it, I originally thought that these 2 questions can be done in most half an hour, and the result is a half an hour, but also commissioned a half-day talent! I don't know if it is old, hehe! 1) Realize String tohex (int) to convert a decimal into hexadecimal. (Full Use Algorithm Implementation) 2) Implement a function String Multiply (STING, STRING) of a computational large bit number (such as more than 100-bit).
(Please completely realize the algorithm) (1) string int2HEX (int a_iint) {string string; strret = ""; // if a_iint <0 Then Return NULL; if (a_iint <0) {Return Strret;} INT i; int ITMP; int IResidue; // the residue int quotient; // the quotient char CTMP; for (ITMP = a_iint; itmp> = 16;) {IResidue = itmp% 16; iQuotient = ITMP / 16; if (IResidue> = 10 ) {CTMP = 'a' IResidue - 10;} else // 0 <= IResidue <= 9 {CTMP = '0' IResidue;} strret = CTMP STRET; ITMP = iQuotient;} if (IResidue> = 10 ) {Ctmp = 'a' iQuotient - 10;} else // 0 <= IResidue <= 9 {ctmp = '0' iQuotient;} strret = ctmp strret; return strret;} (2) string multiply (String Multiply a_strMultp1, string a_strMultp2) {string strRet; // the product; int iMultp1Len; // the length of multiplier1 int iMultp2Len; // the length of multiplier2 int iRetLen; // initialize the parameters iMultp1Len = a_strMultp1.length (); iMultp2Len = A_STRMULTP2.LE NGTH (); IRETLEN = 0; Strret = ""; // if Either's length is 0, then EXIT; IF (iMULTP1LEN <= 0 || iMULTP2LEN <= 0) {Return Strret;} Int i; int J; int oc iry ; // the carry; int idigit; // the Digit; char ctmp; iCarry = 0; IDIGIT = 0;