#include <stdio.h> #include <string.h> #include <stdlib.h> #define MaxSize 1000 char *TwoBigNumMult(char *InputMultiplier_1,char *InputMultiplier_2) { int *TempResult = malloc(MaxSize*sizeof(int)); int TempResultEnd = 0; memset(TempResult,0,MaxSize*sizeof(int)); int MultiplierLen_1 = strlen(InputMultiplier_1); int MultiplierLen_2 = strlen(InputMultiplier_2); char *Result = malloc((MultiplierLen_1+MultiplierLen_2+2)*sizeof(char)); memset(Result,0,sizeof(Result)); int ResultEnd = 0; //Plus && Carry int MultiplierEnd_1,MultiplierEnd_2; for(MultiplierEnd_1 = 0;MultiplierEnd_1 < MultiplierLen_1;MultiplierEnd_1 ++) { for(MultiplierEnd_2 = 0;MultiplierEnd_2 < MultiplierLen_2;MultiplierEnd_2 ++) { TempResult[MultiplierEnd_1 + MultiplierEnd_2 + 1] += (InputMultiplier_1[MultiplierEnd_1]-'0') * (InputMultiplier_2[MultiplierEnd_2]-'0'); } } int CarryEnd; for(CarryEnd = MultiplierLen_1+MultiplierLen_2 - 1;CarryEnd > 0;CarryEnd --) { if(TempResult[CarryEnd] >= 10) { TempResult[CarryEnd-1] += TempResult[CarryEnd] / 10; TempResult[CarryEnd] %= 10; } } //store to return //0 screening int OutputFlag = 0; for(;TempResult[TempResultEnd]==0 && TempResultEnd < MultiplierLen_1+MultiplierLen_2;TempResultEnd ++) ; for(ResultEnd = 0;TempResultEnd < MultiplierLen_1+MultiplierLen_2;ResultEnd ++,TempResultEnd ++) { Result[ResultEnd] = TempResult[TempResultEnd] + '0'; OutputFlag = 1; } if(!OutputFlag) { Result[ResultEnd++] = '0'; } Result[ResultEnd] = '