joy2010WonderMaker @ 2021-01-02 19:41:44
给各位大佬亮出代码
#include<bits/stdc++.h>
using namespace std;
int main(){
string a,b;
cin>>a>>b;
int c[a.size()+b.size()]={0};
int j=0,k=0;
if(a.size()>=b.size()){
j=b.size();
k=a.size();
for(int i=0;i<j;i++){
for(int s=0;s<k;s++){
int p1,p2;
p1=(int)(b[i]-'0');
p2=(int)(a[s]-'0');
c[i+s]=c[i+s]+p1*p2;
if(p1*p2>9){
c[i+s+1]=c[i+s+1]+p1*p2/10*10;
c[i+s]=c[i+s]-p1*p2/10*10;
}
}
}
}else{
j=a.size();
k=b.size();
for(int i=0;i<j;i++){
for(int s=0;s<k;s++){
int p1,p2;
p1=(int)(a[i]-'0');
p2=(int)(b[s]-'0');
c[i+s]=c[i+s]+p1*p2;
if(p1*p2>9){
c[i+s+1]=c[i+s+1]+p1*p2/10*10;
c[i+s]=c[i+s]-p1*p2/10*10;
}
}
}
}
if(!c[j+k-1]){
for(int i=j+k-2;i>=0;i++){
cout<<c[i];
}
}else{
for(int i=j+k-1;i>=0;i++){
cout<<c[i];
}
}
return 0;
}
为什么全RE
by 血色黄昏 @ 2021-01-02 19:43:17
@joy2010 敢把数组定在main里的勇士!
by 血色黄昏 @ 2021-01-02 19:44:06
顺便主页双贴危(
by CGDGAD @ 2021-01-02 19:45:18
int c[a.size()+b.size()]={0};
大部分系统中不允许这么定义。
by joy2010WonderMaker @ 2021-01-02 19:45:46
改了还是RE