Quantcast
Viewing all articles
Browse latest Browse all 10

727 – Equation

Problem description , input and output:

http://uva.onlinejudge.org/index.php?option=onlinejudge&Itemid=99999999&page=show_problem&category=&problem=668

In this problem we need to change an infix expression to a posfix expresion, the key words are IN and POS.

INfix means that the operator is between the two “numbers”

POSfix means that the operator is after the two “numbers”

Theres plenty of ways to do this, most of them use stacks but there are other ways using arrays to store the things inside the parenthesis either way you do it there just like three diferent cases:

1- When you receive a number (0-9) you printed

2- if you receive a left parenthesis ‘(‘ you start storing inside the stack

3- if you receive the right parenthesis ‘)’ you start ‘poping’ everything form the stack

4- when you receive and operand you stored to  print it after the two “numbers”

5- last but not least with “numbers” i mean a single number or a bunch of them including the operands


Viewing all articles
Browse latest Browse all 10

Trending Articles