#include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;
typedef struct node * qque;
struct node{
int ele;
node * next;
};
typedef struct queue * Que;
struct queue{
qque front;
qque tail;
}; Que Queinit()
{
Que que=(Que)malloc(sizeof(queue));
que->front=que->tail=0;
return que;
} bool QueEmpty(Que que)
{
return que->front==0;
} int QueFront(Que que)
{
if(que->front)
return que->front->ele;
else {
cout<<"wrong!!"<<endl;
return -1;
}
} int QueLast(Que que)
{
if(que->tail)
return que->tail->ele;
else {
cout<<"wrong !!"<<endl;
return -1;
}
} void PushQue(Que que,int x)
{
qque q=(qque)malloc(sizeof(node));
q->ele=x;
q->next=NULL;
if(que->front)
{
que->tail->next=q;
}
else
{
que->front=q;
}
que->tail=q;
} void DeleteQue(Que que)
{
que->front=NULL;
que->tail=NULL;
} void Pop(Que que)
{
if(que->front)
que->front=que->front->next;
else cout<<"wrong!!!"<<endl;
}

链表实现队列C语言写法的更多相关文章

  1. 教你如何使用Java手写一个基于链表的队列

    在上一篇博客[教你如何使用Java手写一个基于数组的队列]中已经介绍了队列,以及Java语言中对队列的实现,对队列不是很了解的可以我上一篇文章.那么,现在就直接进入主题吧. 这篇博客主要讲解的是如何使 ...

  2. Java数据结构——用双端链表实现队列

    //================================================= // File Name : LinkQueue_demo //---------------- ...

  3. Python脚本语言写法

    Python脚本语言写法 脚本语言的开始行,是指文件中的代码用什么可执行程序去运行它,就这么简单. #!/usr/bin/python是告诉操作系统执行这个脚本的时候,调用/usr/bin下的pyth ...

  4. 不定长链表队列C语言实现

    #ifndef _CONST_H_#define _CONST_H_ #include <stdio.h>#include <stdlib.h> typedef enum { ...

  5. 使用链表实现队列------《数据结构与算法分析-C语言描述》

    经过ubuntu的gcc验证 一.头文件 que_link.h #ifndef _QUE_LINK_H_ #define _QUE_LINK_H_ struct que_record; typedef ...

  6. 由链表初始化看C语言的二级指针

    先来看C语言创建链表.插入节点和遍历链表的一段代码: #include <stdio.h> #include <stdlib.h> typedef int ElemType; ...

  7. 利用 C++ 单向链表实现队列

    利用C++ 单向链表实现数据结构队列,其实和上一篇基本内容相同,仅仅是插入的时候在链表的尾部插入,取元素都是一样的,都从头部取. #pragma once #include "stdio.h ...

  8. chapter11_2 Lua链表与队列

    链表 由于table是动态的实体,所以在Lua中实现链表是很方便的.每个节点以一个table来表示,一个“链表”只是节点table中的一个字段. 该字段包含了对其他table的引用.例如,要实现一个基 ...

  9. 队列queue(2):链表实现队列

    基本概念 队列是只允许在一端进行插入操作,另一端进行删除操作的线性表. 我们规定,允许删除的叫做队首"head",允许插入的叫做队尾"tail". 基本操作 我 ...

随机推荐

  1. python3_ftp文件传输

    Python中的ftplib模块 Python中默认安装的ftplib模块定义了FTP类,其中函数有限,可用来实现简单的ftp客户端,用于上传或下载文件 FTP的工作流程及基本操作可参考协议RFC95 ...

  2. JMeter的安装和目录解析

    Ubuntu系统中jmeter的安装和目录解析 作为一个Linux新手,在使用jdk时,或许会安装配置多次仍然导致无法使用情况(如无法登录系统等),请按如下步骤一步一步安装并配置 相关软件下载地址 J ...

  3. 关于JavaScript对象,你所不知道的事(二)- 再说属性

    说完了对象那些不常用的冷知识,是时候来看看JavaScript中对象属性有哪些有意思的东西了. 不出你所料,对象属性自然也有其相应的特征属性,但是这个话题有点复杂,让我们先从简单的说起,对象属性的分类 ...

  4. DispatcherServlet讲解

    1.1.1.DispatcherServlet作用DispatcherServlet是前端控制器设计模式的实现,提供Spring Web MVC的集中访问点,而且负责职责的分派,而且与Spring I ...

  5. webform button

    https://www.codeproject.com/Questions/412553/differences-between-onClick-and-onClientClick OnClick w ...

  6. STL list用法总结

    2017-08-20 15:17:30 writer:pprp list是一种线性复杂度的容器,很快 /* name : usage of List writer : pprp declare : n ...

  7. 如何将JS里变量的值赋给文本框

    举个栗子: <html><HEAD><script type="text/javascript" language="Javascript1 ...

  8. 如何更改nagios监控默认的检查时间

    /usr/local/nagios/etc/nagios.cfg: interval_length 表示时间单位,默认为60,即1分钟 /usr/local/nagios/etc/objects/se ...

  9. HttpServlet实现serializable

    Java Servlet Technology Overview Servlets are the Java platform technology of choice for extending a ...

  10. Exception occurred during processing request: null报错

    报错, 恶心的一笔. 报错的地方 解决方法: 没注意到...