📄 de-queue .cpp
字号:
/**************************************************************************
**************************************************************************
***************************** DE-QUEUE.CPP *****************************
**************************************************************************
**************************************************************************/
/*************************************************************************
By :
Muhammad Tahir Shahzad [ MTS ]
B.C.S Honours [ 2000-04 ]
Government College University Lahore
Pakistan
E-mail : mtshome@wol.net.pk
Web-Site : www.mts-home.cjb.net [ www.wol.net.pk/mtshome ]
www.mtshome.cjb.net [ www.geocities.com/mtahirshahzad ]
*************************************************************************/
/**************************************************************************/
/**************************************************************************/
//--------------------------- HEADER FILES -----------------------------//
/**************************************************************************/
/**************************************************************************/
/**************************************************************************/
//--------------------------- User Defined -----------------------------//
/**************************************************************************/
# include "Linklist.H"
/**************************************************************************/
/**************************************************************************/
//--------------------- FUNCTION DEFINITIONS ---------------------------//
/**************************************************************************/
/**************************************************************************/
/**************************************************************************/
//------------------ Double_ended_Linked_list_as_Stack( ) --------------//
/**************************************************************************/
Double_Ended_Linked_List_Queue::Double_Ended_Linked_List_Queue( )
{
rear=NULL;
front=NULL;
inserted_element_count=0;
}
/**************************************************************************/
//---------------------- show_main_screen( ) ---------------------------//
/**************************************************************************/
void Double_Ended_Linked_List_Queue::show_double_ended_queue_screen( )
{
cleardevice( );
setcolor(15);
setlinestyle(1,0,3);
rectangle(5,5,getmaxx( )-5,getmaxy( )-5);
setlinestyle(0,0,0);
show_window(5,5,getmaxx( )-5,80);
setfillpattern(fill_pattern,4);
bar(13,13,getmaxx( )-13,72);
settextstyle(2,0,7);
setcolor(0);
outtextxy(18,17,"Implementation of");
outtextxy(18,16,"Implementation of");
setcolor(12);
outtextxy(19,15,"Implementation of");
outtextxy(20,15,"Implementation of");
settextstyle(2,0,9);
setcolor(0);
outtextxy(37,37,"Double Ended Linked List as Queue");
outtextxy(38,37,"Double Ended Linked List as Queue");
outtextxy(38,36,"Double Ended Linked List as Queue");
setcolor(14);
outtextxy(39,35,"Double Ended Linked List as Queue");
outtextxy(40,35,"Double Ended Linked List as Queue");
outtextxy(41,35,"Double Ended Linked List as Queue");
show_window(5,82,305,getmaxy( )-5);
setfillpattern(fill_pattern,9);
bar(14,91,296,getmaxy( )-14);
setcolor(6);
setfillstyle(1,6);
pieslice(215,105,0,360,10);
setcolor(2);
setfillstyle(1,2);
pieslice(245,105,0,360,10);
setcolor(4);
setfillstyle(1,4);
pieslice(275,105,0,360,10);
setcolor(7);
circle(215,105,11);
circle(245,105,11);
circle(275,105,11);
show_window(307,82,getmaxx( )-5,getmaxy( )-5);
settextstyle(7,0,4);
setcolor(0);
outtextxy(16,111,"Press:");
setcolor(10);
outtextxy(17,110,"Press:");
outtextxy(18,110,"Press:");
settextstyle(2,0,6);
setcolor(0);
outtextxy(59,151,"<I> to Insert an Element");
outtextxy(59,171,"<D> to Delete an Element");
outtextxy(59,191,"<E> to Exit");
setcolor(14);
outtextxy(60,150,"<I> to Insert an Element");
outtextxy(61,150,"<I> to Insert an Element");
outtextxy(60,170,"<D> to Delete an Element");
outtextxy(61,170,"<D> to Delete an Element");
outtextxy(60,190,"<E> to Exit");
outtextxy(61,190,"<E> to Exit");
setfillstyle(2,1);
bar(317,92,getmaxx( )-15,getmaxy( )-15);
}
/**************************************************************************/
//--------------------- show_output_screen( ) --------------------------//
/**************************************************************************/
void Double_Ended_Linked_List_Queue::show_double_ended_queue_output_screen( )
{
for(int count=0;count<=187;count++)
{
setfillstyle(1,0);
bar(317,280,getmaxx( )-15,278-count);
bar(317,280,getmaxx( )-15,278+count);
delay(5);
}
setcolor(12);
settextstyle(2,0,5);
outtextxy(415,405,"Double Ended Linked List");
outtextxy(416,405,"Double Ended Linked List");
outtextxy(560,425,"as Queue");
outtextxy(561,425,"as Queue");
setfillstyle(1,6);
bar(414,420,600,422);
bar(560,440,622,442);
setcolor(15);
setlinestyle(0,0,3);
rectangle(330,405,400,435);
setfillstyle(1,9);
bar(346,406,384,434);
setfillstyle(1,8);
bar(331,406,344,434);
setfillstyle(1,7);
bar(386,406,399,434);
setcolor(15);
setlinestyle(0,0,3);
rectangle(345,405,385,435);
setcolor(7);
setlinestyle(0,0,0);
line(337,420,337,460);
line(337,460,415,460);
line(412,457,415,460);
line(412,463,415,460);
line(360,428,360,450);
line(360,450,415,450);
line(412,447,415,450);
line(412,453,415,450);
line(393,420,393,440);
line(393,440,415,440);
line(412,437,415,440);
line(412,443,415,440);
setcolor(15);
setfillstyle(1,15);
pieslice(337,420,0,360,2);
pieslice(393,420,0,360,2);
settextstyle(0,0,1);
setcolor(15);
outtextxy(320,402,"*");
setcolor(9);
settextstyle(2,0,4);
outtextxy(420,454,"Entry->Previous (x=NULL)");
outtextxy(420,442,"Entry->Data");
outtextxy(420,430,"Entry->Next (x=NULL)");
setcolor(11);
settextstyle(0,0,1);
outtextxy(350,417,"0000");
}
/**************************************************************************/
//------------------------------- Insert( ) ----------------------------//
/**************************************************************************/
void Double_Ended_Linked_List_Queue::Insert( )
{
long num=get_element(DOUBLE);
for(int count=1;count<5;count++)
{
setcolor(0);
setfillstyle(1,0);
pieslice(215,105,0,360,10);
delay(250);
setcolor(6);
setfillstyle(1,6);
pieslice(215,105,0,360,10);
delay(250);
}
if(inserted_element_count<15)
{
setcolor(10);
setfillstyle(1,10);
pieslice(245,105,0,360,10);
sound(1500);
delay(800);
nosound( );
setcolor(2);
setfillstyle(1,2);
pieslice(245,105,0,360,10);
}
if(inserted_element_count==15)
{
setcolor(12);
setfillstyle(1,12);
pieslice(275,105,0,360,10);
sound(2500);
delay(1000);
nosound( );
setcolor(4);
setfillstyle(1,4);
pieslice(275,105,0,360,10);
delay(200);
}
entry=new(node);
entry->next=NULL;
entry->previous=NULL;
if(inserted_element_count==15)
{
show_insert_delete_screen(WARNING);
settextstyle(7,0,4);
setcolor(0);
outtextxy(25,277,"Error:");
outtextxy(26,277,"Error:");
setcolor(14);
outtextxy(27,275,"Error:");
outtextxy(28,275,"Error:");
while(!kbhit( ))
{
settextstyle(2,0,8);
setcolor(0);
outtextxy(46,309,"Not enough heap");
outtextxy(47,309,"Not enough heap");
outtextxy(28,335,"space on Screen.");
outtextxy(29,335,"space on Screen.");
setcolor(12);
outtextxy(48,308,"Not enough heap");
outtextxy(49,308,"Not enough heap");
outtextxy(50,308,"Not enough heap");
outtextxy(30,334,"space on Screen.");
outtextxy(31,334,"space on Screen.");
outtextxy(32,334,"space on Screen.");
delay(500);
setfillstyle(1,9);
bar(23,315,277,362);
delay(400);
}
getch( );
clear_element_screen(1);
}
else if(rear==NULL)
{
entry->data=num;
rear=entry;
front=rear;
rear->next=NULL;
rear->previous=NULL;
inserted_element_count++;
}
else
{
entry->data=num;
rear->next=entry;
entry->previous=rear;
rear=entry;
rear->next=NULL;
inserted_element_count++;
}
print_double_ended_queue( );
}
/**************************************************************************/
//---------------------------- Delete( ) -------------------------------//
/**************************************************************************/
void Double_Ended_Linked_List_Queue::Delete( )
{
for(int count=1;count<5;count++)
{
setcolor(0);
setfillstyle(1,0);
pieslice(215,105,0,360,10);
delay(250);
setcolor(6);
setfillstyle(1,6);
pieslice(215,105,0,360,10);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -