#define _crt_secure_no_warnings
#include <stdio.h>
#define MAXSIZE 10
void Add (char a[], Char b[], char c[]);
void Sub (char a[], Char b[], char c[]);
int Get_len (char a[]);
BOOL Max_a (char a[], char b[]);
int main (void)
{
Char A[maxsize];
Char B[maxsize];
Char Sum[maxsize];
bool symbol = TRUE;
bool Maxa = true;
scanf ("%s", a);
scanf ("%s", b);
if (*a! = '-' &&*b! = '-')
{
Symbol = TRUE;
Add (A, B, sum);
}
else if (*a = = '-' &&*b = = '-')
{
Symbol = FALSE;
ADD (a+1, b+1, sum);
}
Else
{
if (*a = = '-')
{
Maxa = Max_a (a+1, b);
if (Maxa)
{
Symbol = FALSE;
Sub (a+1, B, sum);
}
Else
{
Symbol = TRUE;
Sub (b, a+1, sum);
}
}
Else
{
Maxa = Max_a (A, b+1);
if (maxa==true)
{
Symbol = TRUE;
Sub (A, B + 1,sum);
}
Else
{
Symbol = FALSE;
Sub (b + 1, a, sum);
}
}
}
if (!symbol)
printf ("-");
int slen = Get_len (sum);
while (Slen >=0)
{
printf ("%c", sum[slen--]);
}
return 0;
}
void Add (char a[], Char b[], char c[])
{
int alen = Get_len (a);
int blen = Get_len (b);
int clen = 0;
for (int i = 0; i < MAXSIZE; i++)
{
C[i] = ' 0 ';
}
while (Alen >= 0 && blen >= 0)
{
C[clen] = a[alen--] + b[blen--] + C[clen]-48-48;
if (c[clen]>57)
{
C[clen] = C[clen]-10;
++C[CLEN+1];
}
++clen;
}
while (Alen >= 0)
{
C[clen] = a[alen--] + C[clen]-48;
if (c[clen]>57)
{
C[clen] = C[clen]-10;
++c[clen + 1];
}
++clen;
}
while (Blen >= 0)
{
C[clen] = b[blen--] + C[clen]-48;
if (c[clen]>57)
{
C[clen] = C[clen]-10;
++c[clen + 1];
}
++clen;
}
if (C[clen]! = 48)
++clen;
C[clen] = ' + ';
}
void Sub (char a[], Char b[], char c[])
{
int alen = Get_len (a);
int blen = Get_len (b);
int clen = 0;
int symble = 0;
for (int i = 0; i < MAXSIZE; i++)
C[i] = ' 0 ';
while (Blen >= 0)
{
C[clen] = a[alen--]-b[blen--]-symble + 48;
if (C[clen] < 48)
{
C[clen] + = 10;
symble = 1;
}
Else
symble = 0;
++clen;
}
while (Alen >= 0)
{
C[clen] = a[alen--] + C[clen]-symble-48;
if (C[clen] < 48)
{
C[clen] = C[clen] + 10;
symble = 1;
}
Else
symble = 0;
++clen;
}
while (c[clen-1] = = ' 0 ')
--clen;
C[clen] = ' + ';
}
int Get_len (char a[])
{
for (int i = 0; i < MAXSIZE; i++)
{
if (a[i] = = ' + ')
return i-1;
}
}
BOOL Max_a (char a[], char b[])
{
int alen = Get_len (a);
int blen = Get_len (b);
if (Alen>blen)
return true;
else if (Alen < Blen)
return false;
Else
{
for (int i = 0; I <=alen; i++)
{
if (A[i] > B[i])
return true;
if (A[i] < b[i])
return false;
}
}
}
Large number plus subtraction C language contains negative numbers