///
///
// Basic function function basefun.h //
///
//
Void graph ();
Void List ();
Void stack ();
Void queue ();
Void Compositor ();
Void bintree ();
///
///
// Stack function stats stack.cpp / /
///
//
#include "stack.h"
#include "iostream.h"
Const int INT = 13;
Const Double float = 13.33;
Const char char = 'a';
Template
Void Stack_Push (Stack
{
Cout << "Please enter the data item you want to insert:";
TYPE ITEM;
Item;
Stackopp.push (item);
}
Template
Void Stack_POP (Stack
{
IF (! stackopp.isempty ())
{
Cout << "out of the stack data item:";
Cout << stackopp.pop () << Endl;
}
Else
{
Cout << "The stack is already empty!" << Endl;
}
}
Template
Void Stack_ISempty (Stack
{
IF (! stackopp.isempty ())
Cout << "The stack is not available, and there is" << stackopp.getnum () << "data item!" << endl;
Else
Cout << "The stack is empty!" << Endl;
}
Template
Void Stack_gettop (stack
{
IF (! stackopp.isempty ())
Cout << "The top element is:" << stackopp.gettop () << endl;
Else
Cout << "The stack is empty!" << Endl;
}
Template
Void stack_makeempty (stack
{
IF (! stackopp.isempty ())
{
Stackopp.makeempty ();
Cout << "The stack has been destroyed!" << Endl;
}
Else
{
Cout << "Destruction Failure!" << Endl;
}
}
Template
Void Stackini (Type Temp)
{
Stack
DO
{
COUT << "Stack operation:" << Endl
<< "1) Insert Stack" << ENDL
<< "2) Find" << Endl
<< "3) Whether the stack is empty" << Endl << "4) Get Stack Top Data Item" << ENDL
<< "5) Destroy Stack" << ENDL
<< "X) Exit Stack Operation" << ENDL;
INT ITEM;
Item;
Switch (item)
{
Case 1: stack_push (stackopp); Break;
Case 2: stack_pop (stackopp); Break;
Case 3: stack_isempty (stackopp); Break;
Case 4: stack_gettop (stackopp); Break;
Case 5: stack_makeempty (stackopp); Break;
Default: return;
}
WHILE (TRUE);
}
void stack ()
{
INT ITEM;
COUT << "Clear Selection Data Type: 1) Integer 2) Floating Point 3) Character X) Exit:";
Item;
Switch (item)
{
Case 1: stackini (int); Break; // requires the data type according to different users
Case 2: stackini (float); Break;
Case 3: Stackini (Char); Break;
DEFAULT: RETURN; Break;
}
}
///
///
// Queue function function queue.h //
///
//
#include "queue.h"
Const int INT = 13;
Const Double float = 13.33;
Const char char = 'a';
Template
Void queue_enter (queue
{
Cout << "Please enter the data you want to insert into the queue:";
TYPE ITEM;
Item;
Queueopp.enqueue (item);
}
Template
Void queue_del (queue
{
IF (! queueopp.isempty ())
{
COUT << "Data:" << Queueopp.delqueue () << endl;
}
Else
{
Cout << "The queue is empty!" << Endl;
}
}
Template
Void queue_isempty (queue
{
Queueopp.isempty ())
{
Cout << "The queue is empty!" << endl;
}
Else
{
Cout << "queue is not available!" << endl;
}
}
Template
Void queue_getfront (queue
{
IF (! queueopp.isempty ())
{
COUT << "The header element is:" << queueopp.getfront () << endl;
}
Else
{
Cout << "The queue is already!" << endl;}
}
Template
Void queue_makeempty (queue
{
Queueopp.makeempty ();
Cout << "The queue is emptied!" << Endl;
}
Template
Void queueini (Type Temp)
{
Queue
DO
{
COUT << "The operation of the queue:" << Endl
<< "1) Insert Queue" << ENDL
<< "2) Export" << ENDL
<< "3) Queue is empty" << ENDL
<< "4) Get the team head data item" << ENDL
<< "5) Destruction Queue" << ENDL
<< "X) Exit Query Operation" << ENDL;
INT ITEM;
Item;
Switch (item)
{
Case 1: Queue_Enter (QueueOpp); Break;
Case 2: Queue_Del (QueueOpp); Break;
Case 3: Queue_Isempty (QueueOpp); Break;
Case 4: Queue_Getfront (QueueOpp); Break;
Case 5: Queue_makeempty (QueueOpp); Break;
Default: return;
}
WHILE (TRUE);
}
Void queue () // requires the data type according to different users
{
INT ITEM;
COUT << "Clear Selection Data Type: 1) Integer 2) Floating Point 3) Character X) Exit:";
Item;
Switch (item)
{
Case 1: Queueini (int); Break;
Case 2: Queueini (FLOAT); BREAK;
Case 3: Queueini (Char); Break;
DEFAULT: RETURN; Break;
}
}