C Implementing Queue and Stack with array Overview 1 Impleme

C++: Implementing Queue and Stack with array

Overview:

1. Implementing your own Stack and Queue (DO NOT USE STL)

2. Implement a program that read a file and checks whether each line is a palindrome

-Your code MUST have at least one stack and one queue

-Ignore spaces/upper lower case/non-alpha characters, e.g Taco Cat is a palindrome

-Your console output should look something like this:
Taco Cat
Yes

Some other words
No

Solution

#include<iostream>

#include<conio.h>

#include<stdlib.h>

using namespace std;

class stack

{

             int stk[5];

             int top;

      public:

             stack()

              {

                top=-1;

               }

             void push(int x)

              {

                 if(top > 4)

                       {

                           cout <<\"stack over flow\";

                           return;

                       }

                 stk[++top]=x;

                 cout <<\"inserted\" <<x;

               }

             void pop()

               {

                  if(top <0)

                   {

                         cout <<\"stack under flow\";

                         return;

                    }

                    cout <<\"deleted\" <<stk[top--];

                }

             void display()

               {

                   if(top<0)

                    {

                            cout <<\" stack empty\";

                            return;

                    }

                    for(int i=top;i>=0;i--)

                    cout <<stk[i] <<\" \";

                }

};

main()

{

     int ch;

     stack st;

     while(1)

        {

             cout <<\"\ 1.push 2.pop 3.display 4.exit\ Enter ur choice\";

             cin >> ch;

             switch(ch)

              {

               case 1: cout <<\"enter the element\";

                        cin >> ch;

                        st.push(ch);

                        break;

               case 2: st.pop(); break;

               case 3: st.display();break;

               case 4: exit(0);

               }

         }

return (0);

}

C++: Implementing Queue and Stack with array Overview: 1. Implementing your own Stack and Queue (DO NOT USE STL) 2. Implement a program that read a file and che
C++: Implementing Queue and Stack with array Overview: 1. Implementing your own Stack and Queue (DO NOT USE STL) 2. Implement a program that read a file and che
C++: Implementing Queue and Stack with array Overview: 1. Implementing your own Stack and Queue (DO NOT USE STL) 2. Implement a program that read a file and che

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site