High precision multiplication input: two lines, each line represents a non-negative integer (no more than 10000 bits).
Output: the product of two numbers.
*/
# include & ltstdio.h & gt
# include & ltstring.h & gt
# include & ltstdlib.h & gt
# Define the maximum value 1000 1
int bigchenfa(int *sum,int *a,int *b,int la,int lb)? /* High precision multiplication */
{
int i,j,lsum = 0;
memset(sum,0,sizeof(sum));
for(I = 1; I<= laI++) /* Simulate with arrays */
for(j= 1,lsum = I- 1; j & lt= lbj++)
sum[++ lsum]+= b[j]* a[I];
for(I = 1; I<= lsumI++)/* carry processing */
if(sum[I]& gt; = 10)
{
if(sum[lsum]& gt; = 10)
lsum++;
sum[I+ 1]+= sum[I]/ 10;
sum[I]% = 10;
}
Returns lsum/* Returns the number of digits of the product */
}
int main(void)
{
int a[MAX]={0},b[MAX]={0},sum[MAX * 2]= { 0 };
int la=0,lb=0,lsum = 0;
int i,j;
char sa[MAX],sb[MAX];
scanf("%s %s ",sa,sb);
printf("%s * %s = ",sa,sb);
la = strlen(sa);
lb = strlen(sb);
for(i= 1,j = la- 1; I<= lai++, j-)
a[I]= sa[j]-' 0 ';
for(i= 1,j = l b- 1; I<= lbi++, j-)
b[I]= sb[j]-' 0 ';
lsum = bigchenfa(sum,a,b,la,lb);
for(I = lsum; I>0; I-)
printf("%d ",sum[I]);
printf(" \ n ");
System ("suspended");
Returns 0;
}