Exemple #1
0
        private void UpdateSumValue(SumOfValues sumOfValues, int sum)
        {
            if (sum > 10)
            {
                sumOfValues.Carry = 1;

                sumOfValues.AddValue(sum % 10);
            }
            else
            {
                sumOfValues.AddValue(sum);

                sumOfValues.Carry = 0;
            }
        }
Exemple #2
0
        private SumOfValues AddForwardNumbers(Node left, Node right)
        {
            var sumOfValues = new SumOfValues();

            while (left != null)
            {
                var sum = left.Value + right.Value + sumOfValues.Carry;

                UpdateSumValue(sumOfValues, sum);

                left  = left.Next;
                right = right.Next;
            }

            return(sumOfValues);
        }