假设以带头结点的循环链表来表示队列,并且只设一个指针指向队尾,编写相应的置队空、入队、出队算法。并且还要设计直观的用户操作界面,能直观看到操作结果。
#include <iostream>
#include <malloc.h>#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <windows.h>
using namespace std;
typedef int Datatype;
typedef struct Node//指针结构体
{
Datatype data;
struct Node* next;
}Node;
typedef struct//头指针和尾指针结构体
{
struct Node *front;
struct Node *rear;
}QNode,*LinkQueue;
void InitQueue( LinkQueue &Q);//初始化置空队列
void EnQueue( LinkQueue &Q, Datatype x);//入队
Datatype DeQueue( LinkQueue &Q,Datatype &x);//出队
void ShowAllData(LinkQueue &Q);//显示队列所有元素
int main()
{
LinkQueue Q;
Datatype x;
int ch