原来的代码不见了……
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define MAXN 510
typedef struct
{
int n[MAXN];
int len;
int digit;
}Bigint;
Bigint change(char ch[]);//类型转换
void print(Bigint x);//输出
Bigint addtion(Bigint a,Bigint b);
Bigint subtract(Bigint a,Bigint b);
int compare(Bigint a,Bigint b);//比较大整数a,b的大小,a>b时为1
Bigint times(Bigint a,Bigint b);
Bigint inttimes(Bigint a,int b);
int main(void)
{
Bigint a,b,result;
char ch1[MAXN],ch2[MAXN];
int i,j,k;
memset(a.n,0,sizeof(a.n));
memset(b.n,0,sizeof(b.n));
scanf("%s",ch1);
scanf("%s",ch2);
a=change(ch1);
b=change(ch2);
result=times(a,b);
print(result);
return 0;
}
Bigint change(char ch[])
{
Bigint a;
memset(a.n,0,sizeof(a.n));
int i,j,k=0;
a.len=strlen(ch);
if(ch[0]=='-')
{
a.digit=-1;
a.len--;
k++;
}
else
a.digit=1;
for(i=1;i<=a.len;i++)
{
a.n[i]=ch[a.len-i+k]-'0';
}
return a;
}
void print(Bigint x)
{
int i;
if(x.digit==-1)
printf("-");
for(i=x.len;i>=1;i--)
{
printf("%d",x.n[i]);
}
printf("\n");
}
Bigint addtion(Bigint a,Bigint b)
{
Bigint c;
memset(c.n,0,sizeof(c.n));
int i,j,k;
for(i=1;i<=a.len||i<=b.len;i++)
{
c.n[i]+=a.n[i]+b.n[i];
if(c.n[i]>=10)
{
c.n[i]-=10;
c.n[i+1]++;
}
}
c.len=(compare(a,b)>0)?a.len:b.len;
while(c.n[c.len+1]>0)
{
c.len++;
}
if(a.digit==1&&b.digit==1)
c.digit=1;
return c;
}
Bigint subtract(Bigint a,Bigint b)
{
Bigint c,d;
memset(c.n,0,sizeof(c.n));
c.digit=1;
int i,j,k;
j=compare(a,b);
if(j==0)
{
c.len=1;
c.digit=0;
return c;
}
else if(j<0)
{
d=a,a=b,b=d;
c.digit=-1;
}
for(i=1;i<=a.len||i<=b.len;i++)
{
c.n[i]+=(a.n[i]-b.n[i]);
if(c.n[i]<0)
{
c.n[i]+=10;
c.n[i+1]--;
}
}
c.len=(a.len>b.len)?a.len:b.len;
while(c.n[c.len]==0)
{
c.len--;
}
return c;
}
Bigint times(Bigint a,Bigint b)
{
int i,j,k;
Bigint c;
memset(c.n,0,sizeof(c.n));
c.digit=1;
for(i=1;i<=a.len||i<=b.len;i++)
{
c.n[i]+=a.n[i]*b.n[i];
c.n[i+1]=c.n[i]/10;
c.n[i]=c.n[i]%10;
}
c.len=i;
while(c.n[c.len+1]>0)
{
c.len++;
c.n[c.len+1]=c.n[c.len]/10;
c.n[c.len]=c.n[c.len]%10;
}
return c;
}
Bigint inttimes(Bigint a,int b)
{
Bigint c;
memset(b.n,0,sizeof(b.n));
c.digit=a.digit;
int i;
for(i=1;i<=a.len;i++)
{
c.n[i]=
}
}
int compare(Bigint a,Bigint b)
{
int i,j,k;
if(a.len>b.len)
{
return 1;
}
else if(a.len<b.len)
{
return -1;
}
else
{
for(i=a.len;i>=1;i--)
{
if(a.n[i]>b.n[i])
return 1;
else if(a.n[i]<b.n[i])
return -1;
}
}
return 0;
}