growl @ 2018-03-17 11:49:05
//哪位大佬能帮忙看看哪错了?
#include<bits/stdc++.h>
#include<cstring>
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
char al[100],bl[100];
int a[100],b[100],c[100],lena,lenb,lenc,i,j,x;
memset(a,0,sizeof(a));
memset(b,0,sizeof(b));
memset(c,0,sizeof(c));
gets(al);gets(bl);
lena=strlen(al);lenb=strlen(bl);
for(i=0;i<=lena-1;i++) a[lena-1]=al[i]-'0';
for(i=0;i<=lenb-1;i++) a[lenb-1]=bl[i]-'0';
for(i=1;i<=lena;i++)
{
x=0;
for(j=1;j<=lenb;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+lenb]=x;
}
lenc=lena+lenb;
while(c[lenc]==0&&lenc>1)
lenc--;
for(i=lenc;i>=1;i--)
cout<<c[i];
cout<<endl;
return 0;
}
by AThousandSuns @ 2018-03-17 12:24:59
c[i+lenb]=x应该改成c[i+lenb]+=x