Stacks Queues Reverse Reverse Polish

Discussion in 'C++' started by dogbite, Oct 9, 2003.

  1. dogbite

    dogbite Guest

    I need help with an understanding and completing a project in C++ which
    involves takingm a string of characters Example /*-A+BCDE as an input and
    outputting a postfix expression ABC+-D*E/. I have to use a Stack and a Queue.

    I have been given the following main function which I can not change.

    #include"a:utility.h"
    #incude"a:Stack.h"
    #include"a:Queue.h"

    // prototypes for input , pretopost, output and is operator go here

    main()
    { Queue prefixQ, postfixQ;
    char answer;
    do
    {input (prefixQ);
    pretopost (prefixQ, postfixQ);
    output(postfiQ);
    cout<<endl<<"Continue? N for NO:";
    cin<<answer;
    } while (!(answer=='n' || answer'N'));
    }

    and what the heck are .h files am i supposed to write or copy some other
    functions on the same target directory ?

    Also Please be gentle with me i have limited c++ experience.

    Confused biginner??? Thanks
    dogbite, Oct 9, 2003
    #1
    1. Advertising

  2. dogbite

    Ron Natalie Guest

    "dogbite" <> wrote in message news:...

    > I have been given the following main function which I can not change.


    If you can not change it, you are doomed. The code below isn't valid
    C++.

    >
    > #include"a:utility.h"
    > #incude"a:Stack.h"
    > #include"a:Queue.h"

    None of these include files are standard.

    >
    > // prototypes for input , pretopost, output and is operator go here
    >
    > main()


    ERROR. All functions must have a declared return type. Main must have
    a return type of int.
    >
    > and what the heck are .h files am i supposed to write or copy some other
    > functions on the same target directory ?


    I don't know what the heck they are, go gripe at your teacher for a valid file.
    Ron Natalie, Oct 9, 2003
    #2
    1. Advertising

  3. dogbite

    red floyd Guest

    Ron Natalie wrote:
    > "dogbite" <> wrote in message news:...
    >
    >
    >>I have been given the following main function which I can not change.

    >
    >
    > If you can not change it, you are doomed. The code below isn't valid
    > C++.
    >
    >
    >>#include"a:utility.h"
    >>#incude"a:Stack.h"
    >>#include"a:Queue.h"

    >
    > None of these include files are standard.
    >
    >
    >>// prototypes for input , pretopost, output and is operator go here
    >>
    >>main()

    >
    >
    > ERROR. All functions must have a declared return type. Main must have
    > a return type of int.
    >
    >>and what the heck are .h files am i supposed to write or copy some other
    >>functions on the same target directory ?

    >
    >
    > I don't know what the heck they are, go gripe at your teacher for a valid file.
    >
    >


    not to mention that he has "cin << answer" instead of "cin >> answer"
    red floyd, Oct 9, 2003
    #3
  4. dogbite

    dogbite Guest

    "Ron Natalie" <> wrote in message news:<3f85b20c$0$160$>...
    > "dogbite" <> wrote in message news:...
    >
    > > I have been given the following main function which I can not change.

    >
    > If you can not change it, you are doomed. The code below isn't valid
    > C++.
    >
    > >
    > > #include"a:utility.h"
    > > #incude"a:Stack.h"
    > > #include"a:Queue.h"

    > None of these include files are standard.
    >

    I will change these files to standard files. and i have change the
    cin>>answer typeo. Now the question is what should an algorithm for
    this problem look like. I am stil having issue understanding queue and
    stack operations

    > >
    > > // prototypes for input , pretopost, output and is operator go here
    > >
    > > main()

    >
    > ERROR. All functions must have a declared return type. Main must have
    > a return type of int.
    > >
    > > and what the heck are .h files am i supposed to write or copy some other
    > > functions on the same target directory ?

    >
    > I don't know what the heck they are, go gripe at your teacher for a valid file.


    OK i just found out that .h files are copied from a section in the
    book and are not included in the .ccp file but in the same directory.
    It got this.
    dogbite, Oct 10, 2003
    #4
  5. dogbite

    osmium Guest

    dogbite writes:

    > I am stil having issue understanding queue and
    > stack operations


    A queue models the action you see in an orderly line waiting for the
    services of a single bank teller, sometimes called first in first out or
    FIFO. The British meaning of queue if that helps.

    A stack models the action you see in the plate dispenser of a cafeteria,
    sometimes called last in first out or LIFO.

    It may help to write the infix (parenthesized) version of your test equation
    and see how the other two versions were arrived at from that. Then, at
    least, you would know the right answer if you got it.
    osmium, Oct 10, 2003
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ron
    Replies:
    1
    Views:
    892
    Stewart Gordon
    Jul 2, 2003
  2. Replies:
    2
    Views:
    744
    Oliver Wong
    Feb 6, 2006
  3. Ice
    Replies:
    4
    Views:
    5,008
  4. Steve Lambert

    Reverse polish

    Steve Lambert, Dec 19, 2004, in forum: C Programming
    Replies:
    11
    Views:
    636
    infobahn
    Dec 30, 2004
  5. Reverse Polish Ruby

    , Oct 20, 2006, in forum: Ruby
    Replies:
    0
    Views:
    107
Loading...

Share This Page