Jump to content

RPN

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
4 replies to this topic

#1
eyeshere

eyeshere

    Programmer

  • Members
  • PipPipPipPip
  • 179 posts
I have a project which converts infix expressions to postfix like: 1+2 = 12+. I want to implement it using stack. However, I did not understand our teacher's discussion regarding stack. Can somebody suggest a site which offers clear and understandable tutorials for a newbie like me? Or can somebody tutor me about this?


Your help is highly appreciated. Please please. I'm begging.

Much Thanks!

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
You are dealing with two distinct, though related, issues. Are you having trouble with how to use stacks, or with how to convert from infix to postfix? Also, how complicated of expressions do you need to support? I have two tutorials on stacks: http://forum.codecal...ing-arrays.html and http://forum.codecal...sing-lists.html that may be helpful.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
eyeshere

eyeshere

    Programmer

  • Members
  • PipPipPipPip
  • 179 posts
I have problem with both. But, with your help, I think i'll be able to understand it in its simplest way. Thank you.

P.S. Do you have another program that doesn't use iostream.h? Because our teacher only introduced stdlib.h, stdio.h, conio.h, string.h, ctype.h and math.h to us. We also use printf rather than cout.

#4
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
You should be able to replace cin with scanf and cout with printf. Ideally, you would be using the std::stack rather than building your own, but it appears that you are learning how to build a stack, not just use it.

For how to use them, I would suggest you write each number/operator on a piece of paper and think about whether you need to display it or store it as you move from infix to postfix.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#5
eyeshere

eyeshere

    Programmer

  • Members
  • PipPipPipPip
  • 179 posts
Okay. I'll do that.