From bc08cd53e9fa28b8c5fa1844ee384015a30b5e40 Mon Sep 17 00:00:00 2001 From: mohit0003 <31645375+mohit0003@users.noreply.github.com> Date: Sat, 23 Oct 2021 10:47:43 +0530 Subject: [PATCH] Update stack_using_list.cpp --- stack_using_list.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/stack_using_list.cpp b/stack_using_list.cpp index 1e777b1..cc400de 100644 --- a/stack_using_list.cpp +++ b/stack_using_list.cpp @@ -108,22 +108,22 @@ void SLinkedList::addFront(string e) void SLinkedList::addBack(string e) { if(head==0) - head=new SNode(e); - else - { - SNode *prev,*temp=head; + head=new SNode(e); + else + { + SNode *prev,*temp=head; while(temp) { - prev=temp; - temp=temp->next; + prev = temp; + temp = temp->next; } - prev->next=new SNode(e); + prev->next = new SNode(e); } } void SLinkedList::removeFront() { if(!head) - cout<<"\n\tUNDERFLOW"; + cout<<"\n\tUNDERFLOW"; else { SNode *temp=head; @@ -178,6 +178,7 @@ int main() cout<<"\n\n\t3.POP"; cout<<"\n\n\tENTER YOUR CHOICE"; cin>>choice; + switch(choice) { case 1:cout<<"\n\n\tENTER THE ELEMENT : "; @@ -197,6 +198,7 @@ int main() cout<<"\n\n\tDO U WANT TO CONTINUE?"; cin>>ch; - }while(ch=='Y'||ch=='y'); + + } while(ch=='Y'||ch=='y'); getch(); }