#include <iostream>
#include <vector>
#include <string>
using namespace std;
vector<int> mul(vector<int> &A, int b) {
vector<int> C; //结果数组
//t保存进位
for(int i = 0, t = 0; i < A.size() || t; i++) {
if(i < A.size()) {
t += A[i] * b;
}
C.push_back(t % 10); //压入本位数组
t /= 10; //计算进位
}
return C;
}
int main() {
string a;
int b;
cin >> a >> b;
//将高精度的整数各位存入数组中,从个位开始
vector<int> A;
for(int i = a.size() - 1; i >= 0; i--) {
A.push_back(a[i]-'0');
}
vector<int> res = mul(A, b);
for(int i = res.size() - 1; i >= 0; i--) {
cout << res[i];
}
cout << endl;
return 0;
}
来源:CSDN
作者:i_meteor_shower
链接:https://blog.csdn.net/i_meteor_shower/article/details/104157250