30分++循环链队列++好的追加30

来源:百度知道 编辑:UC知道 时间:2024/06/06 15:14:00
请帮我再加一个“判断队空”和“清空”的功能,回传方式用“引用”谢谢
#include <string>
#include <iostream.h>

typedef int DateType;
struct Node;
typedef struct Node *PNode;

struct Node//结点结构
{
DateType info;
PNode link;
};
//函数声明
int isEmptyQueue_link(PNode &p);
void enQueue_link(PNode &p,DateType x);
void deQueue_link(PNode &p);
DateType frontQueue_link(PNode &p);
void scan_link(PNode &p);

//主函数
void main()
{
PNode head=NULL;
int i=1,x,y;
while(i)
{
printf("**********************************************************************\n");
printf("请选择:1 判断队列是否为空 2 进队列 3 出队列 4 取队列头部元素的值\n");
printf(" 0 退出程序\n");
printf("**********************************************************************\n");
scanf("%d",&i);

switch(i)
{case 1:y=isEmptyQueue_link(head);

#include <iostream>

using namespace std;

typedef int DateType;
typedef struct Node *PNode;
struct Node
{
DateType info;
PNode link;
};

int isEmptyQueue_link(PNode &p);
void enQueue_link(PNode &p,DateType x);
void deQueue_link(PNode &p);
//清空
void deAllQueue_link(PNode &p);
DateType frontQueue_link(PNode &p);
void scan_link(PNode &p);

int main()
{
PNode head=NULL;//修改后,我将head指向了最后插入的节点,改个名字[pLast]也许直观些.
int i=1,x,y;
while(i)
{
printf("****************************\n");
printf("请选择:1 判断队列是否为空 2 进队列 3 出队列 4 取队列头部元素的值 5清空\n");
printf(" 0 退出程序\n");
printf("****************************\n");
scanf("%d",&i);
switch(i)
{case 1:y=isEmptyQueue_link(head);
if(y==1)
printf("队列为空!\n");
else printf("队列非空!\n");
break;