yiyezhiqiu1011 @ 2024-10-18 13:43:05
#include <bits/stdc++.h>
using namespace std;
int main()
{
char s1[2005],s2[2005];
int n1[2005]={},n2[2005]={},ans[2000005]={};
cin >> s1 >> s2;
int ls1=strlen(s1),ls2=strlen(s2),la=0;
//初始化int数组
for (int i = 0; i < ls1; i++)
n1[ls1 - i - 1] = s1[i] - '0';
for (int i = 0; i < ls2; i++)
n2[ls2 - i - 1] = s2[i] - '0';
//计算乘法
la = max(ls1,ls2);
for (int i = 0; i < ls1; i++)
{
for (int j = 0; j < ls2; j++)
{
ans[i] += n1[i] * n2[j];
ans[i+1] += ans[i] / 10;
ans[i] %= 10;
}
}
while (ans[la])
la++;
for (int i = la-1; i >= 0; i--)
{
cout << ans[i];
}
return 0;
}
by SEAN2022NAES @ 2024-10-18 13:51:04
《ans[2000005]={}
》