高精度乘法
作者:互联网
#include<iostream> #include<cstring> #include<cmath> using namespace std; char a[10010], b[10010]; int A[10010], B[10010], C[10010]; int main() { cin >> a >> b; int la = strlen(a), lb = strlen(b),lc=la+lb; for (int i = 0; i < la;i++)A[la -i] = a[i] - '0'; for (int i = 0; i < lb;i++)B[lb - i] = b[i] - '0'; for(int i=1;i<=la;i++) for (int j = 1; j <= lb; j++) { C[i + j - 1] += A[i] * B[j]; C[i + j] += C[i + j - 1] / 10; C[i + j - 1] %= 10; } //100*0=000 while (C[lc] == 0 && lc > 1)lc--; for (int i = lc; i > 0; i--) cout << C[i]; }
高精度讲解:https://www.bilibili.com/video/BV1LA411v7mt?p=3
标签:include,lb,lc,la,int,高精度,10010,乘法 来源: https://www.cnblogs.com/wxywhs/p/15828246.html