1. 7 Write a method to implement *, - , / operations. You should use only the + operator.
直接贴答案吧。。
With an understanding of what each operation (minus, times, divide) does, this problem can
be approached logically.
»» Subtraction should be relatively straightforward, as we all know that a - b is the same thing as a + (-1)*b.
»» Multiplication: we have to go back to what we learn in grade school: 21 * 3 = 21 + 21 + 21. It’s slow, but it works.
»» Division is the trickiest, because we usually think of 21 / 3 as something like “if you divide
a 21 foot board into 3 pieces, how big is each piece?” If we think about if the other way
around (eg, the reciprocal), it’s a little easier: “I divided a 21 foot board in x pieces and
got pieces of 3 feet each, how many pieces were there?” From here, we can see that if we
continuously subtract 3 feet from 21 feet, we’ll know how many pieces there are. That is,
we continuously subtract b from a and count how many times we can do that.