flashfear @ 2024-11-07 17:29:27
第一个点wa了,就第一个。帮帮
#include<stdio.h>
#include<string.h>
int main(){
int arr1[10100]={0},arr2[10100]={0},ans[10100]={0};
char str1[10100]={'\0'},str2[10100]={'\0'};
scanf("%s%s",str1,str2);
int len1=strlen(str1);
int len2=strlen(str2);
for(int i=0;i<len1;i++){
arr1[len1-i-1]=str1[i]-'0';
}
for(int i=0;i<len2;i++){
arr2[len2-i-1]=str2[i]-'0';
}
int temp=0;
for(int i=0;i<len1;i++)
for(int j=0;j<len2;j++){
ans[j+i]+=arr1[i]*arr2[j];
if(ans[j+i]>=10){
temp=ans[i+j]/10;
ans[j+i]%=10;
ans[j+i+1]+=temp;
}
}
if(ans[len1+len2-1]!=0) printf("%d",ans[len1+len2-1]);
for(int i=len1+len2-2;i>=0;i--){
printf("%d",ans[i]);
}
return 0;
}
by wujunxi206 @ 2024-11-07 17:40:57
@flashfear 删前导零
by Inter12 @ 2024-11-07 17:48:17
@flashfear 注意0的情况
by flashfear @ 2024-11-07 18:19:57
@Inter12 @wujunxi206 谢谢指点。(赞)