Class bigreduce: bigcalculate
{
Public override string evaluate (string num1, string num2)
{
Bool isminus = false;
// Determine whether the calculation result is a positive number (that is, whether num1 is greater than num2). If it is equal, 0 is directly returned.
// If the result is negative, replace num1 and num2 and add '-' before the return value '-'
If (num1.equals (num2 ))
{
Return "0 ";
}
Else if (max (num1, num2). Equals (num2) // if the expected calculation result is negative, set num1
Num2 exchange
{
Changenum (ref num1, ref num2 );
Isminus = true;
}
# Region myregion
// Obtain a large number of digits
Int Len = num1.length> num2.length? Num1.length:
Num2.length;
// Add the decimal difference to 0
String tempnum1 = new string ('0', len-num1.length) + num1;
String tempnum2 = new string ('0', len-num2.length) + num2;
Int flag = 0; // carry character
List Lich = new list (); // stores the calculated number
For (INT I = len-1; I> = 0; I --)
{
If (tempnum1 [I]> = tempnum2 [I] + flag)
{
Lich. Add (char) (tempnum1 [I]-tempnum2 [I]-flag + '0 '));
Flag = 0;
}
Else
{
Lich. Add (char) (tempnum1 [I]-tempnum2 [I]-flag + 10 +
'0 '));
Flag = 1;
}
}
// If the result is 0 in the upper order, remove it.
// If the result is negative, the returned result is added "-"
If (isminus = true)
{
Return "-" + invertorder (New
String (lich. toarray (). trimstart ('0 ');
}
Return invertorder (New
String (lich. toarray (). trimstart ('0 ');
# Endregion
}
}