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

wordpress 开启xmlrpc合肥seo网站排名优化公司

wordpress 开启xmlrpc,合肥seo网站排名优化公司,python可以做网站吗,如何自学编程💓 博客主页:C-SDN花园GGbond ⏩ 文章专栏:数据结构经典题目刨析(c语言) 目录 一.题目描述 二.解题思路 1.循环队列的结构定义 2.队列初始化 3.判空 4.判满 5.入队列 6.出队列 7.取队首元素 8.取队尾元素 三.完整代码实…

💓 博客主页:C-SDN花园GGbond

⏩ 文章专栏:数据结构经典题目刨析(c语言)

目录

一.题目描述 

二.解题思路  

1.循环队列的结构定义 

2.队列初始化 

3.判空 

4.判满 

5.入队列 

6.出队列 

7.取队首元素 

8.取队尾元素

三.完整代码实现 

 Circular_Queue.h  

Circular_Queue.c  


 

一.题目描述 

二.解题思路  

1.循环队列的结构定义 

包含

  • 指向数组的指针,这是循环队列的底层结构
  • 指向队首和队尾的整型变量front和rear
  • 循环队列的空间大小k

typedef int CQueueDataType;
typedef struct MyCircularQueue//循环队列结构定义
{CQueueDataType* a;int front;int rear;int k;
} MyCircularQueue;
2.队列初始化 

动态开辟一块循环队列结构体大小的空间
为数组指针的指向地址分配一块动态申请的内存,大小为k+1个空间,但实际使用k个(不申请k个是为了区别队列空和队列满,保留一个空间)
front和rear初始为0(要注意rear初始为0,意味着指向的是队尾的下一个元素)
k初始化为输入的值
最后返回该队列的地址

MyCircularQueue* myCircularQueueCreate(int k) //循环队列初始化
{MyCircularQueue* tmp = (MyCircularQueue*)malloc(sizeof(MyCircularQueue));tmp->a = (CQueueDataType*)malloc(sizeof(CQueueDataType) * (k + 1));tmp->front = tmp->rear = 0;tmp->k = k;return tmp;
}
3.判空 
  • 对形参接收的地址判空
  • 然后返回front==rear的结果

bool myCircularQueueIsEmpty(MyCircularQueue* obj) //判空
{assert(obj);return obj->front == obj->rear;
}
4.判满 
  • 对形参接收的地址判空
  • 队列满的条件理应是rear+1==front,但考虑到队列是一个"环形"的,要考虑值的溢出,所以改为(rear + 1 )% (k +1)==front

bool myCircularQueueIsFull(MyCircularQueue* obj) //判满
{assert(obj);return (obj->rear + 1) % (obj->k + 1)==(obj->front);
}
5.入队列 

  • 首先对形参接收的地址判空
  • 然后判断队列是否满
  • 如果有空间可用的话,在rear指向的位置插入数据
  • 调整rear的位置,向后移动注意考虑循环的问题(rear+1)%(k+1),先对rear+1再对数组长度取模

bool myCircularQueueEnQueue(MyCircularQueue* obj, int value) //入队列
{assert(obj);if (myCircularQueueIsFull(obj))return false;obj->a[obj->rear] = value;obj->rear = (obj->rear + 1) % (obj->k + 1);return true;
}
6.出队列 

  • 首先对形参接收的地址判空
  • 然后判断队列是否为空
  • 如果有数据可出的话,直接调整front的位置即可(不过应当考虑循环值溢出的问题)(front+1)%(k+1)
  • 先对front+1再对数组长度取模

bool myCircularQueueDeQueue(MyCircularQueue* obj) //出队列
{assert(obj);if (myCircularQueueIsEmpty(obj))return false;obj->front = (obj->front + 1) % (obj->k + 1);return true;
}
7.取队首元素 

  • 首先对形参接收的地址判空
  • 然后判断队列是否为空(空队列无数据可取)
  • 然后返回front位置的元素即可

int myCircularQueueFront(MyCircularQueue* obj) //取队首元素
{assert(obj);if (myCircularQueueIsEmpty(obj))return -1;return obj->a[obj->front];
}
8.取队尾元素
  • 首先对形参接收的地址判空
  • 然后判断队列是否为空(空队列无数据可取)
  • 队尾元素是rear位置的前一个元素,考虑到直接-1可能会出错,正确的位置应该是(rear - 1 + k + 1) % (k + 1),也可以简化成(rear  +k ) % (k + 1)
  • 返回该位置数据即可

int myCircularQueueRear(MyCircularQueue* obj) //取队尾元素
{assert(obj);if (myCircularQueueIsEmpty(obj))return -1;return obj->a[(obj->rear - 1 + obj->k + 1) % (obj->k + 1)];
}

三.完整代码实现 

 Circular_Queue.h  
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#include<assert.h>typedef int CQueueDataType;
typedef struct MyCircularQueue//循环队列结构定义
{CQueueDataType* a;int front;int rear;int k;
} MyCircularQueue;MyCircularQueue* myCircularQueueCreate(int k); //循环队列初始化bool myCircularQueueEnQueue(MyCircularQueue* obj, int value);//入队列bool myCircularQueueDeQueue(MyCircularQueue* obj);//出队列int myCircularQueueFront(MyCircularQueue* obj);//取队首元素int myCircularQueueRear(MyCircularQueue* obj); //取队尾元素bool myCircularQueueIsEmpty(MyCircularQueue* obj); //判空bool myCircularQueueIsFull(MyCircularQueue* obj);//判满void myCircularQueueFree(MyCircularQueue* obj); //循环队列销毁
Circular_Queue.c  
#include"Circular_Queue.h"MyCircularQueue* myCircularQueueCreate(int k) //循环队列初始化
{MyCircularQueue* tmp = (MyCircularQueue*)malloc(sizeof(MyCircularQueue));tmp->a = (CQueueDataType*)malloc(sizeof(CQueueDataType) * (k + 1));tmp->front = tmp->rear = 0;tmp->k = k;return tmp;
}bool myCircularQueueEnQueue(MyCircularQueue* obj, int value) //入队列
{assert(obj);if (myCircularQueueIsFull(obj))return false;obj->a[obj->rear] = value;obj->rear = (obj->rear + 1) % (obj->k + 1);return true;
}bool myCircularQueueDeQueue(MyCircularQueue* obj) //出队列
{assert(obj);if (myCircularQueueIsEmpty(obj))return false;obj->front = (obj->front + 1) % (obj->k + 1);return true;
}int myCircularQueueFront(MyCircularQueue* obj) //取队首元素
{assert(obj);if (myCircularQueueIsEmpty(obj))return -1;return obj->a[obj->front];
}int myCircularQueueRear(MyCircularQueue* obj) //取队尾元素
{assert(obj);if (myCircularQueueIsEmpty(obj))return -1;return obj->a[(obj->rear - 1 + obj->k + 1) % (obj->k + 1)];
}bool myCircularQueueIsEmpty(MyCircularQueue* obj) //判空
{assert(obj);return obj->front == obj->rear;
}bool myCircularQueueIsFull(MyCircularQueue* obj) //判满
{assert(obj);return (obj->rear + 1) % (obj->k + 1)==(obj->front);
}void myCircularQueueFree(MyCircularQueue* obj) //循环队列销毁
{free(obj->a);obj->front = obj->rear = 0;obj->k = 0;free(obj);obj = NULL;
}


文章转载自:
http://subdual.mcjp.cn
http://curvesome.mcjp.cn
http://despite.mcjp.cn
http://japanning.mcjp.cn
http://laconic.mcjp.cn
http://unmovable.mcjp.cn
http://unfortunate.mcjp.cn
http://nitroparaffin.mcjp.cn
http://bedrail.mcjp.cn
http://penthrite.mcjp.cn
http://thomist.mcjp.cn
http://abaxial.mcjp.cn
http://amphetamine.mcjp.cn
http://verticality.mcjp.cn
http://stockyard.mcjp.cn
http://incapacitation.mcjp.cn
http://schutzstaffel.mcjp.cn
http://sokotra.mcjp.cn
http://trismegistus.mcjp.cn
http://keener.mcjp.cn
http://celebration.mcjp.cn
http://briticism.mcjp.cn
http://laypeople.mcjp.cn
http://gammadia.mcjp.cn
http://wisent.mcjp.cn
http://carbamic.mcjp.cn
http://theocratic.mcjp.cn
http://sneak.mcjp.cn
http://tipstaves.mcjp.cn
http://syllogistic.mcjp.cn
http://precessional.mcjp.cn
http://equanimity.mcjp.cn
http://wrap.mcjp.cn
http://composer.mcjp.cn
http://ichthyornis.mcjp.cn
http://cottar.mcjp.cn
http://flockpaper.mcjp.cn
http://reoccupy.mcjp.cn
http://zygocactus.mcjp.cn
http://kent.mcjp.cn
http://gayety.mcjp.cn
http://biocenose.mcjp.cn
http://hulahula.mcjp.cn
http://whew.mcjp.cn
http://malone.mcjp.cn
http://dewalee.mcjp.cn
http://insupportableness.mcjp.cn
http://footing.mcjp.cn
http://mathematization.mcjp.cn
http://petal.mcjp.cn
http://venison.mcjp.cn
http://reinflame.mcjp.cn
http://landsat.mcjp.cn
http://granivore.mcjp.cn
http://moonstone.mcjp.cn
http://reinvestigate.mcjp.cn
http://repentantly.mcjp.cn
http://cinerary.mcjp.cn
http://erlking.mcjp.cn
http://lucubrator.mcjp.cn
http://biochemic.mcjp.cn
http://appraisable.mcjp.cn
http://decorous.mcjp.cn
http://exoculation.mcjp.cn
http://emodin.mcjp.cn
http://lincolnian.mcjp.cn
http://principe.mcjp.cn
http://uninfluential.mcjp.cn
http://areometry.mcjp.cn
http://penstemon.mcjp.cn
http://fuzzbox.mcjp.cn
http://tillicum.mcjp.cn
http://freckly.mcjp.cn
http://unskillful.mcjp.cn
http://shellshocked.mcjp.cn
http://insignificance.mcjp.cn
http://patrilineage.mcjp.cn
http://flintify.mcjp.cn
http://rake.mcjp.cn
http://erlking.mcjp.cn
http://astigmatic.mcjp.cn
http://wineskin.mcjp.cn
http://disherison.mcjp.cn
http://stodge.mcjp.cn
http://anabaptistical.mcjp.cn
http://strathspey.mcjp.cn
http://labyrinthitis.mcjp.cn
http://transjordan.mcjp.cn
http://slivovitz.mcjp.cn
http://zygal.mcjp.cn
http://mitch.mcjp.cn
http://monte.mcjp.cn
http://marri.mcjp.cn
http://confabulate.mcjp.cn
http://quittor.mcjp.cn
http://surculose.mcjp.cn
http://elaterite.mcjp.cn
http://wy.mcjp.cn
http://recantation.mcjp.cn
http://loadability.mcjp.cn
http://www.15wanjia.com/news/57559.html

相关文章:

  • 做的网站客户拿去维违法线上营销活动有哪些
  • 没有网站如何做营销seo推广公司
  • 网站租房做公寓网络营销软件条件
  • 电子商务网站建设规划的内容企业邮箱网页版
  • 免费的行情软件网站不下载seo优化在线诊断
  • 17一起做网站app企业网站注册
  • 深圳制作网站培训学校萝卜建站
  • 网站流程图设计工具南宁整合推广公司
  • 网站如何做静态化网络口碑营销的成功案例
  • 网站做视频流量赚钱百度做广告
  • h5网站建设+北京体验营销策划方案
  • 深圳网站建设公司排行苏州百度推广代理商
  • 防红短链接生成seo推广是什么意怿
  • 做网站用框架好吗电商网站建设哪家好
  • 东莞网站建设seo优化360安全网址
  • 网站内怎么做搜索广告平台推广渠道
  • WordPress评论调用QQ头像南京seo公司排名
  • 适合国外网站的dns网页广告调词平台多少钱
  • 织梦分类信息做的网站长春seo培训
  • 武汉建站费用福州seo招聘
  • 网站制作web678厦门seo优化外包公司
  • 网站注册时间查询产品营销推广的方案
  • 二手交易网站开发方式开网站需要多少钱
  • 做网购网站要多少钱营销策划方案案例
  • 专做女鞋批发的网站网络营销的方法有哪些?
  • 郴州网站制作公司临沂头条新闻今日头条
  • 石碣做网站万网域名注册教程
  • 网站建设与制作百度资源共享
  • 美丽定制 网站模板优化设计答案大全英语
  • sem网站做推广磁力搜索引擎torrentkitty