博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
程序猿面试宝典(第三版)--队列的建立,測长,打印,入队,出队
阅读量:6883 次
发布时间:2019-06-27

本文共 1019 字,大约阅读时间需要 3 分钟。

编程实现队列的建立,測长,打印,入队,出队。

#include
#include
#include
#include
using namespace std;typedef struct student{ int data; struct student *next;}node;typedef struct linkqueue{ node *front; node *rear;}queue;queue *create(){ queue *q; q=new queue; q->front=NULL; q->rear=NULL; return q;}int length(queue *HQ){ if(HQ==NULL||HQ->rear==NULL) { cout<<"队列的长度为:0"<
front; while(p!=NULL) { p=p->next; i++; } cout<<"队列的长度为:"<
<
front; cout<<"队列中的元素:";// if(p==NULL) { cout<<"空队列"<
data<<" ";//打印 p=p->next; } cout<
data=num; s->next=NULL; cout<
data<<"入队。";// if(HQ->front==NULL)//if(HQ->rear==NULL)//在空队列中进行元素入队操作 { HQ->front=s; HQ->rear=s; } else { HQ->rear->next=s; HQ->rear=s; } cout<
front==NULL)//HQ->reat==NULL//在空队列中进行元素出队操作 printf("空队列"); else { x=HQ->front->data; p=HQ->front; cout<
front==HQ->rear)//队列中仅仅有一个元素 { HQ->front=NULL; HQ->rear=NULL; } else { HQ->front=HQ->front->next; } free(p); } cout<
执行结果:

你可能感兴趣的文章
UNIX网络编程——ICMP报文分析:端口不可达
查看>>
UNIX网络编程——客户/服务器程序设计示范(八)
查看>>
男生的长相到底有多重要?
查看>>
ubuntu18.04下安装mariaDB
查看>>
Java Object 对象上的wait(),notify(),notifyAll()方法理解
查看>>
性能测试的类型(负载/压力/并发/可靠性)
查看>>
js中的回调函数的理解和使用
查看>>
为什么要写博客
查看>>
灵活运用 SQL SERVER FOR XML PATH
查看>>
WPF创建单独资源库并在应用中引用
查看>>
面向对象的理解
查看>>
perl脚本备份还原sqlserver
查看>>
shell coding about mac ox
查看>>
SQL Server MySQL 中的 in 与 null
查看>>
python----脚本文件的头部写法。
查看>>
jQuery Ajax
查看>>
Cardboard虚拟现实开发初步(一)
查看>>
看懂JSP声明的格式。。。
查看>>
偶然看到网上有人对C和C++关系的概述
查看>>
链表的C语言实现之单链表的实现
查看>>