Defines two functions, I want to apply them in the main function, but now seems to enter the infinite loop,,,
I don't know what went wrong,,,
The ball ball you look to the child, the child have withered,
#include
#include
Char jia (char s [10100], char ss [10100])
{
Int a [10100], [10100] b;
int len;
Int l1=strlen (s);
Int l2=strlen (ss);
Len=(l1 & gt; L2)? L1, l2,
Memset (a, 0, sizeof (a));
Memset (b, 0, sizeof (b));//a, b array initialization
For (int I=l1-1; I>=0; I -)//two loop will input string upside down and converted into a number assigned to a, b integer arrays, data types implicit conversion
A [l1 - I - 1]=s [I] - '0';
For (int I=l2-1; I>=0; I -)
B=ss [l2 - I - 1] [I] - '0';
for(int i=0; i
A [I]=[I] a [I] + b;//temporary number, this is to use an array of wonderful place HHHH
A [I + 1] +=a, [I]/.//digit
A [I]=[I] a % 10;//leave number
}
If (a [len]!=0)
Len++;//the output to use
While (a [] len - 1==0 & amp; & Len> 1)
Len -;//detection output effective digits
For (int I=len - 1; I>=0; I -)//output
Printf (" % d ", a [I]);
printf("\n");
}
Char jian (char s [10100], char ss [10100])
{
Int a [10100], [10100] b;
int len;
Int l1=strlen (s);
Int l2=strlen (ss);
Int flag=0;//a variable records of plus or minus
Memset (a, 0, sizeof (a));
Memset (b, 0, sizeof (b));
If (l1 & lt; L2 | | (STRCMP (s, ss) & lt; 0 & amp; & L1==l2))//comparison before and after the two Numbers size
{
Flag=1;//negative
For (int I=l2-1; I & gt;=0; I -)//reverse input
A [l2 - I - 1]=ss [I] - '0';//to the character in the string is converted to a digital
For (int I=l1-1; I & gt;=0; I -)
B=[l1 - I - 1] s [I] - '0';
}
The else
{
For (int I=l1-1; I>=0; I -)
A [l1 - I - 1]=s [I] - '0';
For (int I=l2-1; I>=0; I -)
B=ss [l2 - I - 1] [I] - '0';
}
Len=(l1 & gt; L2)? L1, l2,
for(int i=0; i
A [I]=[I] a [I] - b;//staging result
If (a [I] <0)
{
A - [I + 1]=1;
A [I] +=10;//a borrow
}
}
While (a [] len - 1==0 & amp; & Len> 1)
Len -;
If (flag==1)
Printf (" - ");//if the result is negative, the first output a minus sign
For (int I=len - 1; I>=0; I -)
Printf (" % d ", a [I]);
printf("\n");
}
Int main ()
{
Char eq [3] [501]={} '\ 0', s [10100], ss [10100];
Int j=0, I=0;
While (eq [I] [j]=getchar ())
{
If (eq [0] [j]=='+' | | eq [0] [j]=='-')
{
Eq [1] [0]=eq [0] [j];//operator position transfer
Eq [0] [j]='\ 0';//the position clear
I=2;
J=0;
}
The else
j++;
}
Strcpy (s, eq [0]);
Strcpy (ss, eq [2]);
If (eq [1] [0]=='+')//computation and high precision add
{
Jia (s, ss);
}
The else
{
Jian (s, ss);
}
return 0;
}