基本功能函数 BaseFun.h
来源:互联网 发布:如何在淘宝拍照购物 编辑:程序博客网 时间:2024/05/16 08:46
///////////////////////////
// //
// 基本功能函数 BaseFun.h //
// //
//////////////////////////
void GRAPH();
void LIST();
void STACK();
void QUEUE();
void COMPOSITOR();
void BINTREE();
///////////////////////////
// //
// 堆栈功能函数 Stack.cpp/ /
// //
//////////////////////////
#include"Stack.h"
#include"iostream.h"
const int INT =13;
const double FLOAT= 13.33;
const char CHAR ='a';
template<class Type>
void Stack_Push(Stack<Type> &StackOPP)
{
cout<<"请输入要插入的数据项: ";
Type item;
cin>>item;
StackOPP.Push(item);
}
template<class Type>
void Stack_Pop(Stack<Type> &StackOPP)
{
if(!StackOPP.ISEmpty())
{
cout<<"出栈数据项: ";
cout<<StackOPP.Pop()<<endl;
}
else
{
cout<<"堆栈已经为空!"<<endl;
}
}
template<class Type>
void Stack_ISEmpty(Stack<Type> &StackOPP)
{
if(!StackOPP.ISEmpty())
cout<<"堆栈不空,还有"<<StackOPP.GetNum()<<"数据项!"<<endl;
else
cout<<"堆栈为空!"<<endl;
}
template<class Type>
void Stack_GetTop(Stack<Type> &StackOPP)
{
if(!StackOPP.ISEmpty())
cout<<"栈顶元素为:"<<StackOPP.GetTop()<<endl;
else
cout<<"堆栈为空!"<<endl;
}
template<class Type>
void Stack_MakeEmpty(Stack<Type> &StackOPP)
{
if(!StackOPP.ISEmpty())
{
StackOPP.MakeEmpty();
cout<<"堆栈已经销毁!"<<endl;
}
else
{
cout<<"销毁失败!"<<endl;
}
}
template<class Type>
void StackINI(Type temp)
{
Stack<Type> StackOPP;
do
{
cout<<"堆栈的操作: "<<endl
<<" 1) 插入堆栈"<<endl
<<" 2) 出栈"<<endl
<<" 3) 堆栈是否为空"<<endl
<<" 4) 得栈顶数据项"<<endl
<<" 5) 销毁堆栈"<<endl
<<" X) 退出堆栈操作"<<endl;
int item;
cin>>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<<"清选择数据类型: 1) 整型 2) 浮点型 3) 字符型 X) 退出: ";
cin>>item;
switch(item)
{
case 1: StackINI(INT); break; //根据不同的用户需要选择数据类型
case 2: StackINI(FLOAT); break;
case 3: StackINI(CHAR); break;
default: return ; break;
}
}
///////////////////////////
// //
// 队列功能函数 Queue.h //
// //
//////////////////////////
#include"Queue.h"
const int INT =13;
const double FLOAT= 13.33;
const char CHAR ='a';
template<class Type>
void Queue_Enter(Queue<Type> &QueueOPP)
{
cout<<"请输入要插入队列的数据: ";
Type item;
cin>>item;
QueueOPP.EnQueue(item);
}
template<class Type>
void Queue_Del(Queue<Type> &QueueOPP)
{
if(!QueueOPP.ISEmpty())
{
cout<<"出队数据:"<<QueueOPP.DelQueue()<<endl;
}
else
{
cout<<"队列已为空!"<<endl;
}
}
template<class Type>
void Queue_ISEmpty(Queue<Type> &QueueOPP)
{
if(QueueOPP.ISEmpty())
{
cout<<"队列已空!"<<endl;
}
else
{
cout<<"队列不空!"<<endl;
}
}
template<class Type>
void Queue_GetFront(Queue<Type> &QueueOPP)
{
if(!QueueOPP.ISEmpty())
{
cout<<"队头元素为: "<<QueueOPP.GetFront()<<endl;
}
else
{
cout<<"队列已空!"<<endl;
}
}
template<class Type>
void Queue_MakeEmpty(Queue<Type> &QueueOPP)
{
QueueOPP.MakeEmpty();
cout<<"队列清空!"<<endl;
}
template<class Type>
void QueueINI(Type temp)
{
Queue<Type> QueueOPP;
do
{
cout<<"队列的操作: "<<endl
<<" 1) 插入队列"<<endl
<<" 2) 出队"<<endl
<<" 3) 队列是否为空"<<endl
<<" 4) 得队头数据项"<<endl
<<" 5) 销毁队列"<<endl
<<" X) 退出队列操作"<<endl;
int item;
cin>>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() //根据不同的用户需要选择数据类型
{
int item;
cout<<"清选择数据类型: 1) 整型 2) 浮点型 3) 字符型 X) 退出: ";
cin>>item;
switch(item)
{
case 1: QueueINI(INT); break;
case 2: QueueINI(FLOAT); break;
case 3: QueueINI(CHAR); break;
default: return ; break;
}
}
// //
// 基本功能函数 BaseFun.h //
// //
//////////////////////////
void GRAPH();
void LIST();
void STACK();
void QUEUE();
void COMPOSITOR();
void BINTREE();
///////////////////////////
// //
// 堆栈功能函数 Stack.cpp/ /
// //
//////////////////////////
#include"Stack.h"
#include"iostream.h"
const int INT =13;
const double FLOAT= 13.33;
const char CHAR ='a';
template<class Type>
void Stack_Push(Stack<Type> &StackOPP)
{
cout<<"请输入要插入的数据项: ";
Type item;
cin>>item;
StackOPP.Push(item);
}
template<class Type>
void Stack_Pop(Stack<Type> &StackOPP)
{
if(!StackOPP.ISEmpty())
{
cout<<"出栈数据项: ";
cout<<StackOPP.Pop()<<endl;
}
else
{
cout<<"堆栈已经为空!"<<endl;
}
}
template<class Type>
void Stack_ISEmpty(Stack<Type> &StackOPP)
{
if(!StackOPP.ISEmpty())
cout<<"堆栈不空,还有"<<StackOPP.GetNum()<<"数据项!"<<endl;
else
cout<<"堆栈为空!"<<endl;
}
template<class Type>
void Stack_GetTop(Stack<Type> &StackOPP)
{
if(!StackOPP.ISEmpty())
cout<<"栈顶元素为:"<<StackOPP.GetTop()<<endl;
else
cout<<"堆栈为空!"<<endl;
}
template<class Type>
void Stack_MakeEmpty(Stack<Type> &StackOPP)
{
if(!StackOPP.ISEmpty())
{
StackOPP.MakeEmpty();
cout<<"堆栈已经销毁!"<<endl;
}
else
{
cout<<"销毁失败!"<<endl;
}
}
template<class Type>
void StackINI(Type temp)
{
Stack<Type> StackOPP;
do
{
cout<<"堆栈的操作: "<<endl
<<" 1) 插入堆栈"<<endl
<<" 2) 出栈"<<endl
<<" 3) 堆栈是否为空"<<endl
<<" 4) 得栈顶数据项"<<endl
<<" 5) 销毁堆栈"<<endl
<<" X) 退出堆栈操作"<<endl;
int item;
cin>>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<<"清选择数据类型: 1) 整型 2) 浮点型 3) 字符型 X) 退出: ";
cin>>item;
switch(item)
{
case 1: StackINI(INT); break; //根据不同的用户需要选择数据类型
case 2: StackINI(FLOAT); break;
case 3: StackINI(CHAR); break;
default: return ; break;
}
}
///////////////////////////
// //
// 队列功能函数 Queue.h //
// //
//////////////////////////
#include"Queue.h"
const int INT =13;
const double FLOAT= 13.33;
const char CHAR ='a';
template<class Type>
void Queue_Enter(Queue<Type> &QueueOPP)
{
cout<<"请输入要插入队列的数据: ";
Type item;
cin>>item;
QueueOPP.EnQueue(item);
}
template<class Type>
void Queue_Del(Queue<Type> &QueueOPP)
{
if(!QueueOPP.ISEmpty())
{
cout<<"出队数据:"<<QueueOPP.DelQueue()<<endl;
}
else
{
cout<<"队列已为空!"<<endl;
}
}
template<class Type>
void Queue_ISEmpty(Queue<Type> &QueueOPP)
{
if(QueueOPP.ISEmpty())
{
cout<<"队列已空!"<<endl;
}
else
{
cout<<"队列不空!"<<endl;
}
}
template<class Type>
void Queue_GetFront(Queue<Type> &QueueOPP)
{
if(!QueueOPP.ISEmpty())
{
cout<<"队头元素为: "<<QueueOPP.GetFront()<<endl;
}
else
{
cout<<"队列已空!"<<endl;
}
}
template<class Type>
void Queue_MakeEmpty(Queue<Type> &QueueOPP)
{
QueueOPP.MakeEmpty();
cout<<"队列清空!"<<endl;
}
template<class Type>
void QueueINI(Type temp)
{
Queue<Type> QueueOPP;
do
{
cout<<"队列的操作: "<<endl
<<" 1) 插入队列"<<endl
<<" 2) 出队"<<endl
<<" 3) 队列是否为空"<<endl
<<" 4) 得队头数据项"<<endl
<<" 5) 销毁队列"<<endl
<<" X) 退出队列操作"<<endl;
int item;
cin>>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() //根据不同的用户需要选择数据类型
{
int item;
cout<<"清选择数据类型: 1) 整型 2) 浮点型 3) 字符型 X) 退出: ";
cin>>item;
switch(item)
{
case 1: QueueINI(INT); break;
case 2: QueueINI(FLOAT); break;
case 3: QueueINI(CHAR); break;
default: return ; break;
}
}
- 基本功能函数 BaseFun.h
- 数据结构-基本功能函数-向量
- 数据结构-基本功能函数-栈
- 数据结构-基本功能函数-链表
- python--函数基本功能
- 整理NLPIR基本功能函数
- Stata基本功能及其函数实现
- vs2008\drivers\opengl_2.h.c_opengl基本功能介绍+示例
- 第六天:基本功能再填充:Decode函数L2和L1
- 2015华为软赛(五)——基本功能函数
- Excel从0到1:基本功能和常用函数
- ctype.h中函数
- string.h中的函数
- string.h中的函数
- string.h中的函数
- time.h 函数说明
- string.h中的函数
- PlaySound函数[mmsystem.h]
- 链表数据结构 list.h
- 图数据结构 graph.h
- 排序算法数据结构 Compositor.h
- 二叉树数据结构 BinTree.h
- 郁闷的一天
- 基本功能函数 BaseFun.h
- 链表 List.h
- 图功能函数 Graph.h
- 排序算法功能函数 Compositor.cpp
- 二叉树功能函数 BinTree.cpp
- 一个字,强!这种图片都能拍到..
- 偶们的书计算机图形学实验教程出版纪念
- Tomcat 和 MySQL的配置全集
- Sun Java 2 Standard Edition SDK 1.5的安装