char* multiply(char* n1, char* n2) {
int result[100000] = { 0 };
int n1len = strlen(n1);
int n2len = strlen(n2);
int sumlen = n1len + n2len;
int i, j, tempmul, tempsum, sidx, idx;
char* res;
for (i = n1len - 1; i >= 0; i--) {
for (j = n2len - 1; j >= 0; j--) {
tempmul = (n1[i] - '0') * (n2[j] - '0');
tempsum = tempmul + result[i + j + 1];
result[i + j] += tempsum / 10;//把商放到result里面的i+j位置
result[i + j + 1] = tempsum % 10;//把余数放到result里面的i+j位置
}
}
for (sidx = 0; sidx < sumlen - 1 && result[sidx] == 0; sidx++);//找到result中不为0的位置
res = (char*)malloc((sumlen - sidx + 1));
idx = 0;
for (i = sidx; i < sumlen; i++) {
res[idx++] = result[i] + '0';//把result中的数字转换为字符存储到res中
}
res[idx] = '\0';
return res;
}