ايران ويج

نسخه‌ی کامل: C++ Stack Program Implementing PostFix Notation
شما در حال مشاهده‌ی نسخه‌ی متنی این صفحه می‌باشید. مشاهده‌ی نسخه‌ی کامل با قالب بندی مناسب.
کد:
#include <string.h>
#include <iostream.h>
#include <conio.h>

class Stack
{
    private:
        int S[50];
        int top;
    public:
        Stack(void);
        void Push(int elem);
        int Pop(void);
        int Top(void);
        int Empty(void);
};

Stack::Stack(void)
{
    top=-1;
}

void Stack::Push(int elem)
{
    top++;
    S[top]=elem;
}

int Stack::Pop(void)
{
    int temp = S[top];
    top--;
    return temp;
}

int Stack::Top(void)
{
    return S[top];
}

int Stack::Empty(void)
{
    if(top<0)
    return 1;
    else
    return 0;
}

void main()
{
    clrscr();
    Stack S1;
    int a,b,c,d,e;
    int count=0;
    char arit[30];

    cout<<"Enter a Number: ";
    cout<<"\nA: ";
    cin>>a;
    cout<<"B: ";
    cin>>b;
    cout<<"C: ";
    cin>>c;
    cout<<"D: ";
    cin>>d;
    cout<<"E: ";
    cin>>e;

    cout<<endl;

    cout<<"Enter Arithmetic Notation: ";
    cin>>arit;

    for (int i=0;i<strlen(arit);i++)

    {

        if (arit=='a'||arit=='b'||arit=='c'||arit=='d'||arit=='e'||arit=='A'||arit=='B'||arit=='C'||arit=='D'||arit=='E')
         {




    getch();
}