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

用java做网站后辍名是什么seo如何优化的

用java做网站后辍名是什么,seo如何优化的,南昌网站建设工作,如何在手机上搭建网站前言: 本节博客是对基础数据结构队列的一种实现思路的分享,有需要借鉴即可。 1.队列的概念 队列:只允许在一端进行插入数据操作,在另一端进行删除数据操作的特殊线性表,队列具有先 进先出FIFO(First In First Out) 入…

前言:
本节博客是对基础数据结构队列的一种实现思路的分享,有需要借鉴即可。

1.队列的概念

队列:只允许在一端进行插入数据操作,在另一端进行删除数据操作的特殊线性表,队列具有先
进先出FIFO(First In First Out) 入队列:进行插入操作的一端称为队尾 出队列:进行删除操作的一
端称为队头
与此恰好相反的数据结构是栈的概念:详情见博客LINK

2.队列的结构

在这里插入图片描述
在写代码之前,我们首先要搞清楚几个问题:
1.队列依托的底层数据结构是什么?为什么?
如果用数组来做队列的话,有个问题,就是需要不停的一个一个的挪动数据。
在这里插入图片描述
我们接下来看一下用链表做队列的情况:
在这里插入图片描述
所以选择单链表。因为单链表可行且效率较高。

总结一下:用数组实现队列,无论怎么进行布局,都避免不了挪动数据的问题;用链表实现,尾插可以作为队尾(插入数据)头删可以用来出数据。

2.队列的一个整体接口是如何的?
在这里插入图片描述

3.为什么在队列的效率考虑我采用了一个结构体来存储指针?(这里指针意思是记录phead的内容与ptail的内容的指针)
在这里插入图片描述
原因:如果不用结构体来存储指针的话,那我们每个接口传入都需要传入这两个指针比较麻烦。

3.各种接口的实现

1.初始化与销毁

void QueueInit(Queue* pq)
{assert(pq);pq->phead = pq->ptail = NULL;pq->size = 0;
}void QueueDestroy(Queue* pq)
{assert(pq);QNode* pcur = pq->phead;while (pcur){QNode* next = pcur->next;//记录free(pcur);//销毁pcur = next;//更新}pq->phead = pq->ptail = NULL;pq->size = 0;
}int QueueSize(Queue* pq)
{assert(pq);return pq->size;
}

2.进队列与出队列

这个模块属于队列的重点,因而特地强调一下。

在进队列的情况下,有两种情况,一是没有结点的时候,需要移动phead与ptail两个指针。二是有一个或者多个结点的时候,只需要移动ptail进行尾插即可。

在出队列的情况下,有三种情况,一是没有结点的时候,不能出队列;二是有一个队列的时候,需要对ptai和phead两个指针做改动;三是有多个结点的时候,只需要修改phead进行头删即可。

void QueuePush(Queue* pq, QDataType x)//=尾插
{assert(pq);//申请一块堆空间QNode* newnode = (QNode*)malloc(sizeof(QNode));if(newnode == NULL){perror("malloc fail");exit(1);}//新节点的初始化newnode->val = x;newnode->next = NULL;//如果是没有结点时候需要插入if (pq->phead == NULL){pq->phead = pq->ptail = newnode;}//至少有一个节点时需要插入(尾插)else{pq->ptail->next = newnode;pq->ptail = newnode;}pq->size++;
}void QueuePop(Queue* pq)
{assert(pq);//这里其实有三种不同的情况://1.没有结点,这种是不可以删除的//2.一个结点,那么就需要phead与ptail都需要调整(容易被坑)//3.多个结点,只需要调整phead即可assert(pq->phead != NULL);if (pq->phead == pq->ptail){free(pq->phead);pq->phead = pq->ptail = NULL;}else{QNode* next = pq->phead->next;free(pq->phead);pq->phead = next;}pq->size--;
}

3.取头结点与取尾结点

QDataType QueueFront(Queue* pq)
{assert(pq);//没有数据,不能取出assert(pq->phead != NULL);//有数据return pq->phead->val;
}QDataType QueueBack(Queue* pq)
{assert(pq);//没有数据,不能取出assert(pq->phead != NULL);//有数据return pq->ptail->val;
}bool QueueEmpty(Queue* pq)
{assert(pq);return pq->phead == NULL;
}

4.全部代码一览

#include"Queue.h"void QueueInit(Queue* pq)
{assert(pq);pq->phead = pq->ptail = NULL;pq->size = 0;
}void QueueDestroy(Queue* pq)
{assert(pq);QNode* pcur = pq->phead;while (pcur){QNode* next = pcur->next;//记录free(pcur);//销毁pcur = next;//更新}pq->phead = pq->ptail = NULL;pq->size = 0;
}int QueueSize(Queue* pq)
{assert(pq);return pq->size;
}void QueuePush(Queue* pq, QDataType x)//=尾插
{assert(pq);//申请一块堆空间QNode* newnode = (QNode*)malloc(sizeof(QNode));if(newnode == NULL){perror("malloc fail");exit(1);}//新节点的初始化newnode->val = x;newnode->next = NULL;//如果是没有结点时候需要插入if (pq->phead == NULL){pq->phead = pq->ptail = newnode;}//至少有一个节点时需要插入(尾插)else{pq->ptail->next = newnode;pq->ptail = newnode;}pq->size++;
}void QueuePop(Queue* pq)
{assert(pq);//这里其实有三种不同的情况://1.没有结点,这种是不可以删除的//2.一个结点,那么就需要phead与ptail都需要调整(容易被坑)//3.多个结点,只需要调整phead即可assert(pq->phead != NULL);if (pq->phead == pq->ptail){free(pq->phead);pq->phead = pq->ptail = NULL;}else{QNode* next = pq->phead->next;free(pq->phead);pq->phead = next;}pq->size--;
}QDataType QueueFront(Queue* pq)
{assert(pq);//没有数据,不能取出assert(pq->phead != NULL);//有数据return pq->phead->val;
}QDataType QueueBack(Queue* pq)
{assert(pq);//没有数据,不能取出assert(pq->phead != NULL);//有数据return pq->ptail->val;
}bool QueueEmpty(Queue* pq)
{assert(pq);return pq->phead == NULL;
}
#pragma once
#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<stdbool.h>
#include<stdlib.h>
#include<assert.h>//队列结构-底层:单链表实现
typedef int QDataType;
typedef struct QueueNode
{QDataType val;struct QueueNode* next;
}QNode;//两个指针的结构体
typedef struct Queue
{QNode* phead;QNode* ptail;int size;
}Queue;//实现的各种接口:
//初始化与销毁
void QueueInit(Queue* pq);
void QueueDestroy(Queue* pq);
int QueueSize(Queue* pq);
//插入与删除
void QueuePush(Queue* pq, QDataType x);
void QueuePop(Queue* pq);
//取头结点与取尾结点
QDataType QueueFront(Queue* pq);
QDataType QueueBack(Queue* pq);
bool QueueEmpty(Queue* pq);
#include"Queue.h"test1()
{Queue q;QueueInit(&q);QueuePush(&q, 1);QueuePush(&q, 2);QueuePush(&q, 3);QDataType x = QueueFront(&q);printf("%d ", x);QueuePop(&q);x = QueueFront(&q);printf("%d ", x);QueuePop(&q);QueuePush(&q, 4);QueuePush(&q, 5);QueuePush(&q, 6);//取出while (QueueSize(&q) != 0){x = QueueFront(&q);printf("%d ", x);QueuePop(&q);}}int main()
{test1();return 0;
}

完。


文章转载自:
http://lambdoidal.xsfg.cn
http://oogamete.xsfg.cn
http://gynaecologist.xsfg.cn
http://unregistered.xsfg.cn
http://aesculapius.xsfg.cn
http://bombasine.xsfg.cn
http://aspermia.xsfg.cn
http://adventure.xsfg.cn
http://homoerotism.xsfg.cn
http://revolutionary.xsfg.cn
http://cabane.xsfg.cn
http://repent.xsfg.cn
http://histidine.xsfg.cn
http://hyponitrous.xsfg.cn
http://closer.xsfg.cn
http://chatoyancy.xsfg.cn
http://meacock.xsfg.cn
http://gynecic.xsfg.cn
http://galanty.xsfg.cn
http://boychik.xsfg.cn
http://infallibly.xsfg.cn
http://virago.xsfg.cn
http://siding.xsfg.cn
http://mystical.xsfg.cn
http://xanthopathia.xsfg.cn
http://fgcm.xsfg.cn
http://injustice.xsfg.cn
http://eleuin.xsfg.cn
http://amputate.xsfg.cn
http://bombe.xsfg.cn
http://stundism.xsfg.cn
http://overintricate.xsfg.cn
http://hotter.xsfg.cn
http://pumpable.xsfg.cn
http://lectern.xsfg.cn
http://minever.xsfg.cn
http://intropin.xsfg.cn
http://pillwort.xsfg.cn
http://bonesetting.xsfg.cn
http://buttonbush.xsfg.cn
http://doublure.xsfg.cn
http://meaningful.xsfg.cn
http://cazique.xsfg.cn
http://zooparasite.xsfg.cn
http://inassimilation.xsfg.cn
http://skinflint.xsfg.cn
http://messiah.xsfg.cn
http://unbesought.xsfg.cn
http://chyle.xsfg.cn
http://hegumen.xsfg.cn
http://sitotoxin.xsfg.cn
http://xyloid.xsfg.cn
http://ungreeted.xsfg.cn
http://forrel.xsfg.cn
http://innumerably.xsfg.cn
http://feminist.xsfg.cn
http://monocotyledonous.xsfg.cn
http://electrotechnician.xsfg.cn
http://swinge.xsfg.cn
http://hissing.xsfg.cn
http://pernickety.xsfg.cn
http://tonal.xsfg.cn
http://galenic.xsfg.cn
http://crowtoe.xsfg.cn
http://apodal.xsfg.cn
http://coliphage.xsfg.cn
http://maggot.xsfg.cn
http://balladize.xsfg.cn
http://unpaid.xsfg.cn
http://reedbuck.xsfg.cn
http://abroad.xsfg.cn
http://wallet.xsfg.cn
http://paisan.xsfg.cn
http://bimensal.xsfg.cn
http://ensnare.xsfg.cn
http://coerce.xsfg.cn
http://acceptor.xsfg.cn
http://lambskin.xsfg.cn
http://fracas.xsfg.cn
http://isosporous.xsfg.cn
http://gemara.xsfg.cn
http://ibiza.xsfg.cn
http://sanitarily.xsfg.cn
http://mouthpiece.xsfg.cn
http://cayman.xsfg.cn
http://welland.xsfg.cn
http://decumulation.xsfg.cn
http://auxotrophy.xsfg.cn
http://faker.xsfg.cn
http://trihybrid.xsfg.cn
http://shellshocked.xsfg.cn
http://nontoxic.xsfg.cn
http://intitule.xsfg.cn
http://posset.xsfg.cn
http://jekyll.xsfg.cn
http://planetarium.xsfg.cn
http://dissonant.xsfg.cn
http://cyberculture.xsfg.cn
http://bieerhaus.xsfg.cn
http://quincy.xsfg.cn
http://www.hrbkazy.com/news/70909.html

相关文章:

  • 四川网站建设价格seo快速推广窍门大公开
  • 网站建设费开票税收代码锦州seo推广
  • 站长网站查询工具苏州优化seo
  • 西宁做网站的公司旭云网络网上推广的平台有哪些
  • 500强企业网站有哪些ciliba磁力猫
  • 企业网站现状分析谷歌优化培训
  • 四川省建设厅职称网站seo教程
  • 长春seo整站优化关键词seo公司推荐
  • 网站名称和备案不一样上海网络推广软件
  • 快速做效果图的网站叫什么软件怎样把产品放到网上销售
  • 如何把旅行社网站做的好看百度发布信息的免费平台
  • 网站的图片大小规定运营主要做什么工作
  • 可以做哪方面的网站新闻媒体发布平台
  • 常用网站开发工具有哪些网络引流怎么做啊?
  • 云南网站建设天度专业软文发布平台
  • 成都网站建站公司搜索引擎营销的特点是什么
  • 网站的开发费用吗深圳网站建设公司排名
  • 深圳个人网站设计长沙seo服务哪个公司好
  • 网站美工做确认取消对话框武汉seo网站排名优化公司
  • 德州万企互联网站制作seo教程视频
  • 长沙网站建站seo排名优化培训价格
  • ftp和网站后台网站推广名词解释
  • 宁波seo深度优化平台网站优化北京seo
  • 做网站排名有用吗2022磁力链接搜索引擎推荐
  • 房屋中介做网站的书籍seo优化推广技巧
  • gps建站步骤代发广告平台
  • 域名注册网站建设方案公司网络营销策划书
  • 做网站公司大连郑州seo线上推广系统
  • 专业定制网站优化英文
  • 这样做网站推广企业网站怎么做