现附上代码:
class Solution {
public:
string multiply(string num1, string num2) {
if (num1 == "0" || num2 == "0")return "0";
vector res (num1.size()+num2.size()-1,0);
int len = num1.size()+num2.size()-2;
string ans = "";
for (int i=0;i 0){
digit = overflow%10;
overflow = overflow/10;
ans.append(1,digit+'0');
}
reverse(ans.begin(),ans.end());
res.clear();
vector().swap(res);
return ans;
}
};