大整数乘法
Sample Input
10 1111111111 1111111111
Sample Output
1234567900987654321
#include<stdio.h>
#include<string.h>
void main()
{
int i,j,k,i1,m,i2,n,a[205]={0};
long b,c,d;
char s1[100],s2[100];
scanf("%d",&m);
scanf("%s",s1);
scanf("%s",s2);
d=0;
for(i1=0,k=m-1;i1<m;i1++,k--)
{
for(i2=0,j=m-1;i2<m;i2++,j--)
{
i=i1+i2;
b=a[i]+(s1[k]-48)*(s2[j]-48)+d;
a[i]=b%10;
d=b/10;
}
while(d>0)
{
i++;
a[i]=a[i]+d%10;
d=d/10;
}
n=i;
}
for(i=n;i>=0;i--)
printf("%d",a[i]);
printf("\n");
}