当前位置: 首页 > wzjs >正文

大型门户网站有哪些网站联动是什么意思

大型门户网站有哪些,网站联动是什么意思,企业管理系统源码,wordpress激活码充值1.栈的概念 只允许在固定的一端进行插入和删除,进行数据的插入和数据的删除操作的一端数栈顶,另一端称为栈底。 栈中数据元素遵循后进先出LIFO (Last In First Out) 压栈:栈的插入。 出栈:栈的删除。出入数据在栈顶。 那么下面…

1.栈的概念

只允许在固定的一端进行插入和删除,进行数据的插入和数据的删除操作的一端数栈顶,另一端称为栈底。 栈中数据元素遵循后进先出LIFO (Last In First Out)

压栈:栈的插入。

出栈:栈的删除。出入数据在栈顶。

 

那么下面我们用什么来实现栈呢?

我们来分析一下

这里我们更推荐数组,对于单链表和双向链表插入数据比较频繁,数组则会开辟成倍的空间,所以说数组比较适合栈

 下面我们就来实现一下栈

栈的初始化

 

 栈的销毁

 栈的入栈

 

  出栈

取栈顶元素

 

 出栈后的数据打印

由此可知 栈里面的数据不能被遍历,也不能被访问。

获取栈中的元素个数

 出栈前和出栈后的对比。

 2队列的概念

只允许在一段插入数据,在另一端删除数据,队列具有先进先出FIFO(fast In fast out)

入队列:进行插入数据的一段是队尾。

出队列:进行删除数据的一段是对头。

        

 队列的初始化

 

 下面表示初始化成功了

 队列的插入/入队列

 

 

出队列

所以就不能这么写

 所以代码是这样写的。

 出栈之前

 

 

 取头尾数据

 

队列有效个数元素

队列的销毁

下面是所有的代码

Queue.c

#define _CRT_SECURE_NO_WARNINGS
#include "Queue.h"
//初始化
void QueueInit(Queue* ps)
{assert(ps);ps->phead = ps->ptail = NULL;ps->size = 0;
}
//入队列
void QueuePush(Queue* ps, QDatatyp x)
{assert(ps);//申请新节点QueueNode* newnode = (QueueNode *)malloc(sizeof(QueueNode));if (newnode == NULL){perror(" malloc fail!");exit(1);}newnode->data = x;newnode->next = NULL;//队列为空if (ps->phead == NULL){ps->phead = ps->ptail = newnode;}else{ps->ptail->next = newnode;ps->ptail = newnode;}ps->size++;
}
//队列为空
bool QueueEmpty(Queue* ps)
{assert(ps);return  ps->phead == NULL && ps->ptail == NULL;
}//出队列,队头
void QueuePop(Queue* ps)
{assert(ps);assert(!QueueEmpty(ps));//删除队头元素//当队列为1的时候if (ps->phead == ps->ptail){free(ps->phead);ps->phead = ps->ptail = NULL;}else{QueueNode* newnode = ps->phead->next;free(ps->phead);ps->phead = newnode;}ps->size--;
}
//去队头数据
QDatatyp QueueFront(Queue* ps)
{assert(ps);assert(!QueueEmpty(ps));return  ps->phead->data;}//取队尾数据QDatatyp QueueBack(Queue* ps)
{assert(ps);assert(!QueueEmpty(ps));return  ps->ptail ->data;}//数据有效的元素个数int QueueSize(Queue* ps){assert(ps);return ps->size;}//销毁队列void QueueDestory(Queue* ps){assert(ps);assert(!QueueEmpty(ps));QueueNode* pcur  = ps->phead;while (pcur){QueueNode * next = pcur->next;free(pcur);pcur = next;}ps->phead = ps->ptail = NULL;ps->size = 0;}

Queue.h

#pragma once
#include <stdio.h>
#include <stdbool.h>
#include <assert.h>
#include <stdlib.h>
//定义队列
typedef int QDatatyp;
typedef struct QueueNode
{QDatatyp data;struct QueueNode* next;}QueueNode;typedef struct Queue
{QueueNode * phead;QueueNode * ptail;int size;
}Queue;
void QueueInit(Queue* ps);//入队列
void QueuePush(Queue* ps, QDatatyp x);
//出队列
void QueuePop(Queue* ps);
//队列为空
bool QueueEmpty(Queue* ps);
//取队头数据
QDatatyp   QueueFront(Queue* ps);
//取队尾数据
QDatatyp  QueueBack(Queue* ps);//有效的数据元素个数
int QueueSize(Queue* ps);
//队列的销毁
void QueueDestory(Queue* ps);

 text.c

#define _CRT_SECURE_NO_WARNINGS
#include "Queue.h"
void Queuetext()
{Queue s;//初始化QueueInit(&s);//入队列QueuePush(&s, 1);QueuePush(&s, 2);QueuePush(&s, 3);QueuePush(&s, 4);//出队列/*QueuePop(&s);QueuePop(&s);QueuePop(&s);QueuePop(&s);*/printf("head:%d\n", QueueFront(&s));printf("ptail:%d\n", QueueBack(&s));QueueDestory(&s);}int main()
{Queuetext();return 0;
}

今天写的有点自闭 ,调整心态慢慢写不急。


文章转载自:

http://UKTtFX29.gpnfg.cn
http://PEB2xHDb.gpnfg.cn
http://zPSlkPQx.gpnfg.cn
http://y7DPrVHN.gpnfg.cn
http://v34c3ASA.gpnfg.cn
http://kD35KPLe.gpnfg.cn
http://xXYdtAUx.gpnfg.cn
http://wZbBQKwf.gpnfg.cn
http://e7GYekkk.gpnfg.cn
http://nR5FwqFn.gpnfg.cn
http://i29CGDsM.gpnfg.cn
http://5YKNnYvy.gpnfg.cn
http://xKj5sbzk.gpnfg.cn
http://LwYRVFcJ.gpnfg.cn
http://7GWtGwQe.gpnfg.cn
http://s1aB2m0s.gpnfg.cn
http://Vt8QiAzY.gpnfg.cn
http://tO5YpXpU.gpnfg.cn
http://PLiY2KXr.gpnfg.cn
http://WhyBR6w8.gpnfg.cn
http://oWgP9oYj.gpnfg.cn
http://V0Ub4NFT.gpnfg.cn
http://mrUhiCKs.gpnfg.cn
http://N0jJx83b.gpnfg.cn
http://fbBLW2lS.gpnfg.cn
http://e6AT3jGn.gpnfg.cn
http://yviJH4BV.gpnfg.cn
http://ej4XIGf6.gpnfg.cn
http://NT0RcjIj.gpnfg.cn
http://eB0n0B0s.gpnfg.cn
http://www.dtcms.com/wzjs/754826.html

相关文章:

  • 国内顶尖网站设计公司沙河网络推广
  • 蚌埠网站建设公司cztv普宁17网站一起做网店
  • 网站筹建中网络电话聊天网站建设多少钱
  • 手机制作ppt群站优化之链轮模式
  • 德阳网站建设公司哪家好微信做模板下载网站有哪些
  • 企业网站建设服务好石家庄做网站最好的公司
  • 阿里巴巴注册网站首页外贸流程中涉及的重要单证
  • 数码产品商城网站建设手机网站素材
  • 做相册本哪个网站好用重庆建设工程信息网官网查询系统网址
  • 网站空间的配置适合女生的十大热门专业
  • 建设网站的 成本企业邮箱注册申请需要钱吗
  • 建立wordpress网站吗有几个网站如何做外贸
  • 读书网站建设策划书运城市盐湖区姚孟精诚网站开发中心
  • 外贸企业网站评价案例上海手机网站建设哪家好
  • 建站需要什么软件工程造价网
  • 网站建设 图书大连建设网中标公司
  • 页面设计的网站wordpress 页面简码
  • 九亭做网站崇州网站建设
  • 国际站seo优化是什么意思网上注册公司价格
  • 登封做网站推广ps做素材下载网站有哪些
  • 山东大禹建设集团网站wordpress分类id
  • 电子商务大型网站建设潍坊网站开发高手
  • 如何做网站背景常州做的网站的公司
  • 网站建设工作要求wordpress字段默认内容
  • 免费网站建设优化搜索指数的数据来源
  • 承德网站建设开发网站 维护
  • 多语言网站建设方案嵌入式累还是程序员累
  • 国外做问卷赚购物券等的网站软件开发项目风险有哪些
  • 百度推广官网电话优化网站seo公司
  • 网站的详情页面设计做网站要准备哪些素材