文档介绍:word
word
1 / 9
word
某某
学号
实验项目
栈和队列与其应用〔I〕
实验内容
1.采用顺序存储结构,实现栈的存储和根本操作。
栈的抽象数据类型定义参见教材第45页。
栈的顺序存储结构移动步骤:";
Hanoi(n, x, y, z);
DestoryStack_Sq(S); //销毁栈S
cout << endl;
print();
cout << "实验内容二:采用顺序存储结构,实现队列的存储和根本操作" << endl;
SqQueue Q;
QElemType data;
InitQueue_Sq(Q); //构造一个空队列Q
word
word
3 / 9
word
cout << "请输入需入队列的元素个数:N = ";
cin >> count;
cout << "请输入元素:";
for (int i = 0; i < count; i++)
{
cin >> data;
EnQueue_Sq(Q, data);
}
GetHead_Sq(Q, data);
cout << " 队首元素:" << data << endl;
cout << " 出队列:";
while (DeQueue_Sq(Q, data))
cout << data << " ";
cout << endl;
print();
cout << endl;
}
void print(void)
{
cout << endl << "***********************************************************" << endl;
}
〞〞的局部程序如下:
#ifndef ADT_H_
#defineADT_H_
/************************************************************
* 常量和数据类型预定义
************************************************************/
/* ------函数结果状态代码------ */
#defineTRUE 1
#defineFALSE 0
#defineOK 1
#defineERROR 0
#defineINFEASIBLE -1
#defineOVERFLOW -2
/* ------数据类型预定义------ */
typedefintStatus; //函数结果状态类型
typedefint_bool; //bool状态类型
/************************************************************
*