Http://blog.9 Press .NET / AVALON BBS / Archive / 2004/11/22 / 190842.ASPX
#include
NULL) {free;} while (Temp! = L-> end) {it = TEMP; TEMP = TEMP-> N; Free (IT);} Free (TEMP); Free (L); Return true;} inline void printlist (Listh & l) {// print nodeh it = L-> Head, end = l-> end; if (it == null) return; for (; it! = end; it = IT -> n) PUTCHAR (IT-> Data '0'); Putchar (IT-> Data '0');} Inline Bool Addzero (Listh & l, int count) {// At the tail of L, COUNT 0 While (count -) Endadd (L, 0); Return True;} Inline Bool Bitmul (Listh & L, Const Int Number, Listh & Num) {// The result of the number of numbers is removed in Num // NUM should be empty! ! ! ! ! ! ! ! ! Nodeh L_END = L-> End; int status = 0, TEMP; for (; l_end! = L-> head; l_end = l_end-> p) {temp = l_end-> data * number status; preadd (Num, Temp % 10); status = temp / 10;} temp = l-> Head-> data * number status; if (Temp> 10) {preAdd (Num, Temp% 10); Preadd (Num, TEMP / 10); } Else preadd (NUM, TEMP); // Less one time :) Return True;} Inline Bool Add (Const Listh & la, Listh & lb) {// lb = la lb nodeh pa = la-> end, PB = lb -> end; int status = 0; for (; pa! = la-> head; pa = pa-> p, pb = pb-> p) {if (pb == null) {preAdd (lb, 0); PB = lb-> head;} int sum = pa-> data pb-> data status; if (sum> = 10) {PB-> DATA = SUM% 10; status = 1;} else {PB-> Data = SUM; status = 0;
}}} = F (lb, 0); PB = lb-> head;} int sum = pa-> data pb-> data status; if (sum> = 10) {PB- > DATA = SUM% 10; IF (PB-> P == Null) {preAdd (lb, 0); PB = lb-> head; pb-> data = sum / 10; return true;} PB = PB-> p; if (pb == null) {preAdd (lb, 0); PB = lb-> head;} PB-> DATA = SUM / 10; RETURN TRUE;} else // sum <10 PB-> Data = SUM Return true;} /// inline void mul (const char * a, const char * b) {// INITLH CS = NULL; // Multiplier Listh BCS = NULL; // Multiplier Listh Num = NULL; // 结果 er)) ({// symbol processing int Sig = 1; if ('); {// == * a) { A; SIG * = - 1;} else if (' ' == * a) a; if ('-' == * b) { b; sig * = - 1;} else IF ' ' == * b) B; IF (SIG <0) PUTCHAR ('-');} IF (strcmp (a, b)> 0) {const char * pa = a, * Pb = b; for (; '/ 0'! = * Pa; ) {int Temp = * PA-'0 ' Assert (Endadd (BCS, TEMP));} for (; '/ 0'! = * Pb; Pb) {INT TEMP = * PB-'; Assert (Endadd (CS, TEMP));} } Else {const char * pa = a, * pb = b; for (; '/ 0'! = * Pa; ) {int Temp =
* PA-'0 '; Assert (Endadd (CS, TEMP));} for (;' / 0 '! = * Pb; PB) {INT TEMP = * PB-'; Assert (endAdd (BCS , TEMP));}} // init end !!!! nodeh cs_p = cs-> end; int bit = 0; // digits for (; cs_p! = cs-> head; cs_p = cs_p-> p) {Listh Temp; InitList (Temp); Bitmul (BCS, CS_P-> DATA, TEMP); // Puts ("======================= =================================================== / n "); PrintList (BCS); /// printf ("x% d =", cs_p-> data); PrintList (TEMP); /// // <===================== ========= Here !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Addzero (Temp, Bit); add (Temp , Num); / PUTS ("/ nnum:"); PrintList (NUM); Printf ("/ Nbit:% D / N", BIT); bit; destoryList (Temp);} Listh Temp; Initlist (Temp Bitmul (BCS, CS_P-> DATA, TEMP); // Puts ("================================ ============================================ / n "); PrintList (BCS);