Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "enhanced-stack.hpp"
- ENHANCED_STACK::ENHANCED_STACK() : STACK()
- {
- }
- void ENHANCED_STACK::Print_Stack()
- {
- NODE * temp = HEAD;
- cout << "Stack: ";
- if(Is_Empty())
- {
- cout << "<Empty>";
- }
- else
- {
- while (temp != NULL)
- {
- cout << setw(3) << temp->value;
- temp = temp->link;
- }
- }
- cout << endl;
- }
- void ENHANCED_STACK::Clean()
- {
- int value;
- while(!Is_Empty())
- {
- Pop(value);
- }
- }
- void ENHANCED_STACK::Copy(STACK & S1)
- {
- ENHANCED_STACK temp;
- int value;
- Clean();
- while(!S1.Is_Empty())
- {
- S1.Pop(value);
- temp.Push(value);
- }
- while(!temp.Is_Empty())
- {
- temp.Pop(value);
- Push(value);
- S1.Push(value);
- }
- }
- int ENHANCED_STACK::Equal(STACK & S1)
- {
- ENHANCED_STACK temp1;
- ENHANCED_STACK temp2;
- int flag = 1;
- int value1;
- int value2;
- temp1.Copy(*this);
- temp2.Copy(S1);
- while(!(temp1.Is_Empty() && temp2.Is_Empty()))
- {
- temp1.Pop(value1);
- temp2.Pop(value2);
- if(value1 != value2)
- {
- flag = 0;
- break;
- }
- }
- if(temp1.Is_Empty() && temp2.Is_Empty())
- {
- flag = 0;
- }
- return flag;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement