for expression (((1-1)+3)+3)*7*8 result should be ( 1 - 1 + 3 + 3 ) * 7 * 8)
Commutative Law, Associative Law, and Distributive Law can provide enough heuristic insight for you to implement such. The commutative law in algebra states that when two elements are linked through some binary operation, the result is independent of the order of the elements. The commutative law of addition is: a + b = b + a The commutative law of multiplication is: a x b = b x a Subtraction is not commutative: a - b != b - a The associative law in algebra states that when three or more elements are linked together through a binary operation, the result is independent of how each pair of elements is grouped. The associative law of addition is: a + (b + c) = (a + b) + c The associative law of multiplication is: a × (b × c) = (a × b) × c Subtraction is not associative: a − (b − c) != (a − b) − c The distributive law in algebra describes an operation which when performed on a combination of elements is the same as performing the operation on the individual elements. The distributive law does not work in all cases of arithmetic. For example, multiplication over addition holds: a(b + c) = ab + ac whereas addition over multiplication does not: a + (b × c) != (a + b) × (a + c)
Обсуждают сегодня