关于两个多位数加法
# include<stdio.h>void main()
{
int a[30]={0},
b[30]={0},
c[30]={0},x,y,z,i,j,k,m,n,d;
printf("input x:"); /*第一个数的位数*/
scanf("%d",&x);
printf("Please input a number:\n");
for(i=x-1;i>=0;i--)
scanf("%d",&a[i]);
printf("input y:"); /*第二个数的位数*/
scanf("%d",&y);
printf("Please input another number:\n");
for(j=y-1;j>=0;j--)
scanf("%d",&b[j]);
z=(x>y)?x:y;
d=0;
m=0;
while(m<z)
{
c[m]=a[m]+b[m]+d;
d=c[m]/10;
c[m]=c[m]%10;
m++;
}
if(d==0)
n=z-1;
else
{
c[z]=d;
n=z;
}
printf("The answer is:\n");
for(k=n;k>=0;k--)
printf("%d",c[k]);
}