The common law is multiplied by a large number, and the common law is multiplied by a large number.
The general version of the large number is mainly to convert each character into a character, and then multiply it in turn, followed by the carry method. The specific implementation method is as follows (pure C language ):
# Include <stdio. h>
# Include <stdlib. h>
# Include <string. h>
# Define maxn100
Char * big_mull (char link1 [], char link2 []) {
Int string1 [maxn], string2 [maxn], s [maxn];
Int I, j;
Int len1, len2, len;
Len1 = strlen (link1 );
Len2 = strlen (link2 );
Len = len1 + len2;
For (I = len1-1; I> = 0; I --){
String1 [I] = link1 [len1-i-1]-'0'; // inverted Storage
}
For (I = len2-1; I> = 0; I --){
String2 [I] = link2 [len2-i-1]-'0 ';
}
// For (I = 0; I <= len1-1; I ++ ){
// Printf ("% d", string1 [I]);
//}
// Printf ("\ n ");
// For (I = 0; I <= len2-1; I ++ ){
// Printf ("% d", string2 [I]);
//}
// Printf ("\ n ");
Memset (s, 0, sizeof (s ));
For (I = 0; I <len1; I ++) {// multiply each number
For (j = 0; j <len2; j ++ ){
S [I + j] + = string1 [I] * string2 [j];
}
}
Int c = 0;
For (I = 0; I <len; I ++) {// carry
S [I] + = c;
C = s [I]/10;
S [I] = s [I] % 10;
}
For (I = len-1; I> = 0; I --) {// determine whether there is a 0 high
If (s [I]! = 0)
Break;
}
Len = I + 1;
Char * p; p = (char *) malloc (len) * sizeof (char); // create a string
If (len = 1 ){
P [0] = 0 + '0 ';
P [1] = '\ 0 ';
}
For (I = 0; I <len; I ++) {// array conversion string
P [I] = s [len-i-1] + '0 ';
}
P [len] = '\ 0 ';
Return p;
}
Int main ()
{
Char link1 [maxn], link2 [maxn];
Gets (link1 );
Gets (link2 );
// Big_mull (link1, link2 );
Puts (big_mull (link1, link2 ));
Return 0;
}