All operators have the same precedence and are right
associative, thus 15 - 8 - 3 = 15 - (8 - 3) = 10. As one would expect, brackets
will force the expression within them to be evaluated first. Brackets may be
nested arbitrarily deeply. An expression never has two operators next to each
other (even if separated by a bracket), an assignment operator is always
immediately preceded by a variable and the leftmost operator on a line is
always an assignment. For readability, spaces may be freely inserted into an expression,
except between a negative sign and a number. A negative sign will appear right
before an integer only. All variables are initialized to zero (0) and retain
their values until changed explicitly. In addition, The second operand must be evaluated
first; for example, an expression (A = 10) / (A = 5) evaluates (A = 5) first,
then evaluates (A = 10), and finally evaluates 10 / 5. All integer divisions follow the C/C++ integer division rule and there is no division by zero.
Write
a program that will accept and evaluate expressions written in this language.
Each expression occupies one line and contains at least one assignment
operator, and maybe more.
jung2381187 5년 전
문제 설명의 표 아래부분을 다음과 같이 수정해주세요.
All operators have the same precedence and are right associative, thus 15 - 8 - 3 = 15 - (8 - 3) = 10. As one would expect, brackets will force the expression within them to be evaluated first. Brackets may be nested arbitrarily deeply. An expression never has two operators next to each other (even if separated by a bracket), an assignment operator is always immediately preceded by a variable and the leftmost operator on a line is always an assignment. For readability, spaces may be freely inserted into an expression, except between a negative sign and a number. A negative sign will appear right before an integer only. All variables are initialized to zero (0) and retain their values until changed explicitly. In addition, The second operand must be evaluated first; for example, an expression (A = 10) / (A = 5) evaluates (A = 5) first, then evaluates (A = 10), and finally evaluates 10 / 5. All integer divisions follow the C/C++ integer division rule and there is no division by zero.
Write a program that will accept and evaluate expressions written in this language. Each expression occupies one line and contains at least one assignment operator, and maybe more.
또, 표에 있는 오타 "brracket"을 "bracket"으로 수정해주세요.
다행히 수정할 곳이 많지 않았습니다.