减法就简单多了
#include<stdio.h>
#include<string.h>
int main()
{
char s1[100],s2[100];
int m,t1,t2,t,i,d,a[100]={0},b[100]={0},c[100];
gets(s1);
gets(s2);
t1=strlen(s1);
t2=strlen(s2);
for (i=1;i<=t1;i++)
a[i]=(int)s1[t1-i]-48;
for (i=1;i<=t2;i++)
b[i]=(int)s2[t2-i]-48;
if (t1>=t2) t=t1;
else
{
t=t2;
for (i=1;i<=t2;i++) /*偷个懒,懒得等会考虑小位数减大位数*/
{
m=a[i];
a[i]=b[i];
b[i]=m;
}
printf("-");
}
for (i=1;i<=t;i++)
{
if (a[i]<b[i])
{
a[i+1]=a[i+1]-1;
a[i]=a[i]+10;
}
c[i]=a[i]-b[i];
}
while (c[t]==0 && t>1) t--;
for (i=t;i>0;i--)
printf("%d",c[i]);
return 0;
}