Gianthard_陈昱衡 @ 2020-08-12 11:59:20
代码贴上:
#include<iostream>
#include<stdio.h>
#include<cstring>
using namespace std;
const int maxsize = 2010;
char s[maxsize] = {0};
int a[maxsize] = {0};
int lena;
int b[maxsize] = {0};
int lenb;
int c[maxsize] = {0};
int lenc;
int main(){
scanf("%s",s);
lena = strlen(s);
for(int i=0;i<lena;i++){
a[i] = s[lena - i - 1] - '0';
}
scanf("%s",s);
lenb = strlen(s);
for(int i=0;i<lenb;i++){
b[i] = s[lenb - i - 1] - '0';
}
for(int i=0;i<maxsize;i++){
for(int j=0;j<maxsize;j++){
c[i+j] += a[j] * b[i];
}
}
for(int i=0;i<maxsize;i++){
if(c[i]!=0){
c[i+1]+=c[i] / 10;
c[i] = c[i] % 10;
}
}
for(int i=maxsize - 1;i>=0;i--){
if(c[i]!=0){lenc=i+1;break;}
}
for(int i=lenc - 1;i>=0;i--){
cout<<c[i];
}
return 0;
}
by Franka @ 2020-08-12 12:02:36
@GiantHard 数组开
by Gianthard_陈昱衡 @ 2020-08-12 12:05:53
@Franka 10000我都试过了QwQ还是不行
by Franka @ 2020-08-12 12:07:58
@GiantHard 高精乘打错了咯
by Gianthard_陈昱衡 @ 2020-08-12 12:09:28
@Franka 谢谢大佬qwq
by Franka @ 2020-08-12 12:09:49
@GiantHard
c[i+j] += a[j] * b[i];
不应该是c[i+j-1]吗
by Franka @ 2020-08-12 12:10:14
@GiantHard 还有下表尽量从一开始
by Franka @ 2020-08-12 12:10:21
标
by Gianthard_陈昱衡 @ 2020-08-12 12:20:46
@Franka 好的qwq
by Gianthard_陈昱衡 @ 2020-08-12 12:21:09
@Franka 主要是想尽量节省空间
by Franka @ 2020-08-12 12:22:24
@GiantHard 节省这么点空间?/yiw