ykhykh @ 2016-09-23 20:15:14
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<cstring>
#include<cmath>
using namespace std;
void add(int a[3000],int b[3000])
{
int c[6000];
int i=1,x=0,j=1;
int lc=0;
string s;
string s2;
cin>>s;
cin>>s2;
b[0]=s.length();
for(i=1;i<=b[0];i++)
{
b[i]=s[b[0]-i]-'0';
}
a[0]=s2.length();
for(i=1;i<=a[0];i++)
{
a[i]=s2[a[0]-i]-'0';
}
for(i=1;i<=a[0];i++)
{
x=0;
for(j=1;j<=b[0];j++)
{
c[i+j-1]=a[i]*b[j]+x+c[i+j-1];
x=c[i+j-1]/10;
c[i+j-1]=c[i+j-1]%10;
}
c[i+b[0]]=x;
}
lc=a[0]+b[0];
while(c[lc]==0&&lc>1)
{
lc--;
}
for(i=lc;i>0;i--)
{
printf("%d",c[i]);
}
}
int main()
{
int a[500];
int b[500];
add(a,b);
return 0;
}
by PhantasmDragon @ 2016-09-23 21:21:45
呵呵
by Kyru_Yann @ 2016-09-23 22:15:59
呵呵
by ykhykh @ 2016-09-23 22:17:29
hh
by stone2000 @ 2016-10-26 19:09:51
呵呵
by 为彼此是艳火 @ 2017-05-18 13:48:02
数组开太小了,试试2000 2000 4000000