#include <iostream>#include<cstring>using namespacestd;#defineMAX 1000000structnode{intdata; Node*next;};voidOutput (node*head) { if(!head->next &&!head->data)return; Output (head-next); cout<< head->data;}voidMul (Char*a,Char*b) { Char*ap = A, *BP =b; Node*head =NewNode; Head->data =0; Head->next =NULL; Node*p, *q=head, *P1; inttemp=0, Temp1, bit; while(*BP) {P= q->Next; P1=Q; Bit= *bp- -; while(*ap | |temp) { if(!p) {P=NewNode; P->data =0; P->next =NULL; P1->next =p; } if(*ap = =0) Temp1=temp; Else{Temp1= P1->data + (*ap- -) *bit +temp; AP++; } p1->data = temp1%Ten; Temp= TEMP1/Ten; P1=p; P= p->Next; } AP=A; BP++; Q= q->Next; } P=Head; Output (p); cout<<Endl; while(head) {p= head->Next; DeleteHead; Head=p; }}intMain () {CharA[max], B[max]; Cin.getline (A, MAX,'\ n'); Cin.getline (b, MAX,'\ n'); Mul (Strrev (a), Strrev (b)); return 0;}
Large number multiplication