1 #include <iostream> 2 #include <vector> 3 using namespace std; 4 5 vector<int> mul(vector<int>& A, int &b) 6 { 7 vector<int> C; 8 int t = 0; 9 for (int i = 0; i < A.size() || t; i++) 10 { 11 if (i < A.size()) t += A[i] * b; 12 C.push_back(t % 10); 13 t /= 10; 14 } 15 while(C.size()>1&&C.back() == 0) C.pop_back(); 16 return C; 17 } 18 19 int main() 20 { 21 string a; 22 int b; 23 cin >> a >> b; 24 vector<int> A; 25 for (int i = a.size() - 1; i >= 0; i--) A.push_back(a[i] - '0'); 26 auto C = mul(A, b); 27 for (int i = C.size() - 1; i >= 0; i--) cout << C[i]; 28 return 0; 29 }
标签:10,高精度,int,back,vector,mul,乘法,size From: https://www.cnblogs.com/muzhaodi/p/17723555.html