jiangyunuo @ 2024-08-05 14:58:54
#include<bits/stdc++.h>
using namespace std;
char ch[2005],sh[2005],zh[4005];
int main(){
cin>>ch>>sh;
int len1,len2;
len1=strlen(ch);
len2=strlen(sh);
for(int i=1;i<=len1;i++){
for(int j=1;j<=len2;j++){
if(zh[i+j-2])zh[i+j-2]-=48;
zh[i+j-2]+=(ch[len1-i]-48)*(sh[len2-j]-48);
zh[i+j-2]+=48;
}
}
int len3;
len3=strlen(zh);
for(int i=0;i<len3;i++){
zh[i]-=48;
}
for(int i=0;i<len3;i++){
zh[i+1]+=zh[i]/10;
zh[i]%=10;
}
if(zh[len3]>10){
zh[len3+1]+=zh[len3]/10;zh[len3]%10;len3++;
}
if(zh[len3]<=0)len3--;
for(int i=len3;i>=0;i--){
zh[i]+=48;
cout<<zh[i];
}
return 0;
}
by dongzhen @ 2024-08-05 15:09:49
输入你是从下边为零输入的。但是你的循环是从一开始的,如果你想从一开始。在输入的时候请输入数组名加一,下次注意下标问题喵~。如cin>>(zh+1); @jiangyunuo
by jiangyunuo @ 2024-08-05 15:11:39
@dongzhen ohhhhhhhhhhhhhhhhh,感谢大佬,本人想关,但关注次数满了,本人会另想办法
by TTdd110517 @ 2024-08-05 15:20:18
@jiangyunuo python解法
a=int(input())
b=int(input())
print(a*b)
by jiangyunuo @ 2024-08-05 15:23:24
@TTdd110517 我要c++的
by jiangyunuo @ 2024-08-05 15:36:34
@dongzhen 这又咋了
#include<bits/stdc++.h>
using namespace std;
char ch[2005],sh[2005],zh[4005];
int main(){
bool z=0;
cin>>ch>>sh;
int len1,len2;
len1=strlen(ch);
len2=strlen(sh);
for(int i=0;i<len1;i++){
for(int j=0;j<len2;j++){
if(zh[i+j]!=0)zh[i+j]-=48;
zh[i+j]+=(ch[len1-i-1]-48)*(sh[len2-j-1]-48);
zh[i+j]+=48;
}
}
int len3;
len3=strlen(zh);
for(int i=0;i<len3;i++){
zh[i]-=48;
}
for(int i=0;i<len3;i++){
zh[i+1]+=zh[i]/10;
zh[i]%=10;
}
if(zh[len3]>10){
zh[len3+1]+=zh[len3]/10;zh[len3]%10;len3++;
}
for(int i=len3-1;i>=0;i--){
zh[i]+=48;
if(z)cout<<zh[i];
else{
if(zh[i]!=48){
z=1;
cout<<zh[i];
}
}
}
if(z==0){
cout<<"0"<<endl;
}
return 0;
}
by dongzhen @ 2024-08-05 16:09:45
@jiangyunuo 看来你已经解决啦,本蒟蒻看不出来
by jiangyunuo @ 2024-08-05 16:11:51
@dongzhen 呃,但现在我过了