#include
#include
# define Maxsize 100
# define DataType int
Typedef struct
{
DataType data [Maxsize];
Int top;
} Seqstack, * PSeqstack;
PSeqstack Init_Seqstack ()//initialization stack
{
PSeqstack S;
S=(PSeqstack) malloc (sizeof (Seqstack));
If (S)
S - & gt; Top=1;
return S;
}
Int Empty_Seqstack (PSeqstack S)//to the stack is empty
{
If (S - & gt; Top==1)
{
return 1;
} the else
return 0;
}
Int Push_PSeqstack PSeqstack S, DataType (x)//into the stack
{
If (S - & gt; Top==Maxsize - 1)
{
return 0;
} the else
{
S - & gt; Top++;
S - & gt; Data [S - & gt; top]=x;
return 1;
}
}
Int Pop_PSeqstack (PSeqstack S, DataType * x)//a stack
{
If (Empty_Seqstack (S))
return 0;
The else
{
* x=S - & gt; Data [S - & gt; top];
S - & gt; top--;
//printf (" % d ", * x);
return 1;
}
}
Void High_precision_multiplication (int a [], int [] b, int minlen, int maxlen)
{
Printf (" entered the=========================\ n ");
PSeqstack c, d;
Int a1=0, a2=0;
C=Init_Seqstack ();
D=Init_Seqstack ();
Int result [Maxsize]={0};
for(int i=0; i
Push_PSeqstack (c, a, [I]).
}
for(i=0; i
Push_PSeqstack [I] (d, b);
}//press data into c, d - two stack structure & gt; Is how how to input into the stack structure
//int top=c - & gt; Top;
//printf (" % d=======\ n ", c - & gt; Top);
for(i=0; i
Pop_PSeqstack (d, & amp; A2);
C - & gt; Top=top;
//printf (" % d \ n ", c - & gt; Top);
for(int j=0; j
Pop_PSeqstack (c, & amp; A1);
The result [I + j] +=a1 * a2;
Printf (" 1. The first % d % d \ n ", j, result [I + j]);
The result [I + j + 1) +=result [I + j]/10;
Printf (" (2) the first % d % d \ n ", j, result [I + j + 1));
The result [I + j]=result [I + j] % 10;
Printf (" 3. The first % d % d \ n ", j, result [I + j]);
Printf (" + + + + + + + + + % d \ n ", c - & gt; Top);
}
}
Int len=minlen + maxlen;
While (the result] [len - 1==0 & amp; & Len!
=1){
Len -;
}
For (I=len - 1; I>=0; I -)
{
Printf (" % d ", the result [I]);
}
printf("\n");
}
Void main ()
{
[Maxsize] char a, b [Maxsize], \ [Maxsize];
Int minlen maxlen;
Int [Maxsize] c, d [Maxsize];
While (true)
{
Printf (" please enter the first string: ");
scanf("%s",a);
Printf (" please enter the second string: ");
The scanf (" % s ", b);
If (strlen (a) & gt;=strlen (b))
{
Minlen=strlen (b);
Maxlen=strlen (a);
} the else
{
Maxlen=strlen (b);
Minlen=strlen (a);
}
If (STRCMP (b, a) & gt; 0)/in/with a big b
{
Strcpy (temp, a);
Strcpy (a, b);
Strcpy (b, temp);
}
for(int i=0; i
C=a [I] - [I] '0'.
D=b [I] - [I] '0'.
}
High_precision_multiplication (c, d, minlen, maxlen);
}
}
I want to ask why c - & gt; Top=what is the top of the game use,
I get rid of this program is running the result is not correct, but I don't know what's the use of this line of code, and I know he is c - & gt; When top reset to the initial value, what's the use? I guess he is will affect carry, just don't know why