zjk18759500039 @ 2023-01-25 11:46:52
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
char a[2023], b,c[4068];
int num[4068],cd;
cin >> a;
cd = strlen(a);
for (int j = 0; j < cd; j++)
num[j] = 0;
getchar();
for (int i =0;; i++)
{
b = getchar();
if (a[0] == '0'||(i==0&&b=='0'))
{
cout << 0;
return 0;
}
if (b<'0')
{
cd += i;
break;
}
num[i + cd] = 0;
for (int j=0; j <cd; j++)
num[i + j] += (a[j] - 48) * (b - 48);
}
for (int i = cd - 1; i > 0; i--)
{
c[i] = 48 + (num[i] % 10);
num[i - 1] += num[i] / 10;
}
c[cd-1] = '\0';
if (num[0] > 9)
{
cout << num[0] / 10;
}
c[0] = 48 + (num[0] % 10);
cout << c;
}
by BeBanned @ 2023-01-25 13:40:35
并没有看懂(我太弱了
by zjk18759500039 @ 2023-01-25 15:45:25
@CSMYSL
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
char a[2023], b,c[4068];
int num[4068],cd;
cin >> a;
cd = strlen(a);
for (int j = 0; j < cd; j++)
num[j] = 0;
getchar();
for (int i =0;; i++)
{
b = getchar();
if (a[0] == '0'||(i==0&&b=='0'))
{
cout << 0;
return 0;
}
//特殊情况特殊处理;
if (b<'0')
{
cd += i;
break;
}
//如果遭遇'\n'直接退出该循环
num[i + cd] = 0;
for (int j=0; j <cd; j++)
num[i + j] += (a[j] - 48) * (b - 48);
//不进位的每位数值;
}
for (int i = cd - 1; i > 0; i--)
{
c[i] = 48 + (num[i] % 10);
num[i - 1] += num[i] / 10;
}
c[cd-1] = '\0';
if (num[0] > 9)
{
cout << num[0] / 10;
}
c[0] = 48 + (num[0] % 10);
cout << c;