❓ Help Dev C++

Status
Not open for further replies.

TAEEEEE123

Forum Veteran
#include <iostream>
using namespace std;

struct Node{
int data;
Node *link;
};

Node *top = NULL;

bool isempty(){
if(top == NULL)
return true;
else
return false;
}

void push (int value){
Node *ptr = new Node();
ptr->data = value;
ptr->link = top;
top = ptr;
}

void pop ( ){
if ( isempty() )
cout<<"Stack is Empty";
else{
cout<<("\n");
cout<<top->data <<(" is popped\n");
Node *ptr = top;
top = top -> link;
delete(ptr);
}
}

void displayStack(){
if ( isempty() )
cout<<"Stack is Empty";
else{
Node *temp=top;

while(temp!=NULL){
cout<<temp->data<<" ";
temp=temp->link;
}
cout<<"\n";
}
}

int main(){

int choice, flag=1, value;

cout<<("\n======= Menu =======")<<endl
<<("\n1. Push data") <<endl
<<("2. Pop data") <<endl
<<("3. Display")<<endl
<<("4. Undo")<<endl
<<("5. Delete")<<endl
<<("6. Exit\n");

while( flag == 1){

cout<<("\nEnter choice: ");
cin>>choice;

switch (choice){

case 1: cout<<"Enter Value: ";
cin>>value;
push(value);
break;
case 2: pop();
break;
case 3: displayStack();
break;
case 4:

case 5:

case 6: flag = 0;
break;
}
}
return 0;
}

Anong Logic Coding and gagawin ko para malagayan ng undo saka delete and stack using linked list ko an program??
 
Status
Not open for further replies.

Similar threads

About this Thread

  • 0
    Replies
  • 291
    Views
  • 1
    Participants
Last reply from:
TAEEEEE123

Online now

Members online
755
Guests online
6,185
Total visitors
6,940

Forum statistics

Threads
2,338,653
Posts
29,304,721
Members
1,124,485
Latest member
fobert1
Back
Top