Machuanqi99 @ 2023-10-04 11:30:43
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1001;
char a2[maxn], b2[maxn];
int a[maxn], b[maxn], s, ss, s3, x, c[10001];
int main(){
gets(a2);
gets(b2);
s = strlen(a2);
ss = strlen(b2);
for(int i = 0; i <= s-1; i++) a[s-1] = a2[i] - '0';
for(int i = 0; i <= ss- 1; i++) b[s-1] = b2[i] - '0';
for(int i = 1; i <= s; i++){
x = 0;
for(int j = 1; j <= ss; j++){
c[i+j-1] = a[i]*b[j] + x + c[i+j-1];
x = c[i+j-1]/10;
c[i+j-1] %= 10;
}
c[i+ss] = x;
}
s3 = s+ss;
while(c[s3] == 0 && s3 > 1)
s3--;
for(int i = s3;i >= 1; i--) cout << c[i];
cout << endl;
return 0;
}
by Tony9739416 @ 2023-10-04 11:42:36
可以编译成功呀! 没有问题。
by whdywjd @ 2023-10-04 11:49:34
maxn 应该是 2001 吧。
by lirenzehao @ 2023-10-04 11:52:07
数组开小了