Infix to postfix when have no brackets in the input?

T

tomerdr

Hi,
My infix expression never have brackets,
So how do i convert it to postfix?
For example 112*20 will yield 11220*
Which cannot be correctly evaluate(which is it 1*1220 or 11*220...?)

Is putting brackets when pushing operands on the stack is a good idea?

112*20 will yield (112)(20)* as a postfix string.

Thanks in advance.
 
M

mlimber

Hi,
My infix expression never have brackets,
So how do i convert it to postfix?
For example 112*20 will yield 11220*
Which cannot be correctly evaluate(which is it 1*1220 or 11*220...?)

Is putting brackets when pushing operands on the stack is a good idea?

112*20 will yield (112)(20)* as a postfix string.

Thanks in advance.

This is not a C++ *language* question. See this FAQ for what is
on-topic here:

http://www.parashift.com/c++-faq-lite/how-to-post.html#faq-5.9

If you feel yours is a language question (not an algorithm question
that happens to be implemented in C++!), please rephrase. Otherwise,
I'd recommend you seek help from comp.programming or similar.

Cheers! --M
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top