Browse Source

update rpn

1122-buz-zinga
davidrobert99 2 years ago
parent
commit
94419a83f3
  1. 13
      subjects/rpn/README.md

13
subjects/rpn/README.md

@ -2,17 +2,16 @@
### Instructions
Write a **program** which takes a `string` which contains an equation written in `Reverse Polish Notation` (RPN) as its first argument,
which evaluates the equation, and which prints the result on the standard output followed by a newline (`'\n'`).
Write a **program** which takes a `string` that contains an equation written in `Reverse Polish Notation` (RPN) as an argument. The **program** must evaluate the equation, and then:
`Reverse Polish Notation` is a mathematical notation in which every operator follows all of its operands. In RPN,
every operator encountered evaluates the previous 2 operands, and the result of this operation then becomes the first of
the two operands for the subsequent operator. Operands and operators must be spaced by at least one space.
- If the `string` is not valid or if there is not exactly one argument, `Error` must be printed on the standard output followed by a newline.
- If the `string` has extra spaces it is still considered valid.
`Reverse Polish Notation` is a mathematical notation in which every operator follows all of its operands. In RPN, every operator encountered evaluates the previous 2 operands, and the result of this operation then becomes the first of the two operands for the subsequent operator. Operands and operators must be spaced by at least one space.
The following operators must be implemented : `+`, `-`, `*`, `/`, and `%`.
If the `string` is not valid or if there is not exactly one argument, `Error` must be printed on the standard output followed by a newline.
If the `string` has extra spaces it is still considered valid.
All the given operands must fit in a `i64`.

Loading…
Cancel
Save