今天看到的题如下所示:
Given two numbers represented as strings, return multiplication of the numbers as a string.
Note: The numbers can be arbitrarily large and are non-negative.
Subscribe to see which companies asked this question
是大数乘法的实现,大数由字符串给出,读取字符串部分还没来得及实现:
#include<stdio.h>
#include<string.h>
void str_multi(int m, char* str1, int n, char * str2){
int result[m+n], tmp[n][m+1], a[m], b[n], i, j, count, c;
i = 0;
while(i < m){ //把字符串转换成整数存放到数组中
a[i] = str1[m-i-1] - '0';
i++;
}
i = 0;
while(i < n){
b[i] = str2[n-i-1] - '0';
i++;
}
i = 0;
while(i < n){ //把计算结果放到二维数组中考虑到进位数组的每一行比被乘数长度