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

网页制作素材图片美食网站seo谷歌

网页制作素材图片美食,网站seo谷歌,企业怎么在网站上做宣传,南充房产1.队列的定义 2.队列的分类 2.1循环队 2.2链式队 3.队列的实现 3.1循环队 3.1.1声明 typedef int QDataType; #define MAXSIZE 50 //定义元素的最大个数 /*循环队列的顺序存储结构*/ typedef struct {QDataType *data;int front; //头指针int rear; //尾指针 }Queue;…

1.队列的定义

2.队列的分类

2.1循环队

2.2链式队

3.队列的实现

3.1循环队

3.1.1声明

typedef int QDataType;
#define MAXSIZE 50  //定义元素的最大个数
/*循环队列的顺序存储结构*/
typedef struct {QDataType *data;int front;  //头指针int rear;   //尾指针
}Queue;

3.1.2初始化

void QueueInit(Queue* q) 
{q->data = (QDataType*)malloc(sizeof(QDataType )* MAXSIZE);if (q->data == NULL){perror("malloc fail:");return;}q->front = 0;q->rear = 0;
}

3.1.3判断队列是否为空

bool QueueEmpty(Queue*q)
{assert(q);return q->front == q->rear;
}

3.1.4判断队列是否为满

bool QueueFull(Queue*q)
{assert(q);return q->front == (q->rear+1)%MAXSIZE;
}

3.1.5入队

void QueuePush(Queue* q, QDataType x) 
{assert(q);if(QueueFull){printf("队列已满\n");return ;}q->data[q->rear] = x;   q->rear = (q->rear + 1) % MAXSIZE;  //rear指针向后移一位置,若到最后则转到数组头部
}

3.1.6出队

void QueuePop(Queue* q){assert(q);assert(!QueueEmpty(q));q->front = (q->front + 1) % MAXSIZE;    //front指针向后移一位置,若到最后则转到数组头部}

3.1.7打印队列

void QueuePrint(Queue* q){assert(q);int cur = q->front;printf("队头->");while (cur != q->rear){printf("%d->", q->data[cur]);cur = (cur + 1) % MAXSIZE;}printf("队尾\n");}

3.1.8销毁队列

void QueueDestroy(Deque* q)//销毁队列
{assert(q);free(q->data);q->data = NULL;q->front = q->rear = 0;
}

3.2链

3.2.1声明

typedef int QDataType;
typedef struct QueueNode 
{QDataType data;struct QueueNode* next;
}QNode;
typedef struct Queue 
{QNode* front;QNode* rear;size_t size;
}Queue;

3.2.2初始化

void QueueInit(Queue* q)
{q->front = NULL;q->rear = NULL;q->size = 0;
}

3.2.3判断队列是否为空

bool QueueEmpty(Queue* q)
{assert(q);return (q->front == NULL) && (q->rear == NULL);
}
void QueuePush(Queue* q, QDataType x)
{assert(q);QNode* newnode = (QNode*)malloc(sizeof(QNode));newnode->data = x;newnode->next = NULL;if (newnode == NULL){perror("malloc fail");return;}if (q->front == NULL){q->front = q->rear = newnode;}else{q->rear->next = newnode;q->rear = newnode;}q->size++;
}

3.2.4出队

void QueuePop(Queue* q)
{assert(q);assert(!QueueEmpty(q));//1.只有一个结点if (q->front == q->rear){free(q->front);q->front = q->rear = NULL;}//2.有多个结点else{QNode* del = q->front;q->front = q->front->next;free(del);del = NULL;}q->size--;
}

3.2.5打印队列

void QueuePrint(Queue* q)
{assert(q);QNode* cur = q->front;QNode* tail = q->rear;printf("队头->");while (cur != tail->next){printf("%d->",cur->data);cur = cur->next;}printf("队尾\n");
}

3.2.6销毁队列

void QueueDestroy(Queue* q)
{assert(q);QNode* cur = q->front;while (cur){QNode* del = cur;cur = cur->next;free(del);del = NULL;}q->front = q->rear = NULL;
}

http://www.hkea.cn/news/393710/

相关文章:

  • 长沙网站建设与维护百度开户联系方式
  • 做pcr查基因序列的网站南京百度网站快速优化
  • 数据服务网站策划方案关键词快速优化排名软件
  • 响应式网站缺点学大教育培训机构电话
  • 江苏天德建设工程有限公司网站一个平台怎么推广
  • 石家庄做网络推广的网站推广平台收费标准
  • 贵阳天柱网站建设招聘域名注册平台有哪些
  • 网站建设电话营销百度问一问官网
  • 网站优化建设河南怎么关闭seo综合查询
  • 自贡做响应式网站开发公司google搜索引擎入口google
  • 东莞哪种网站推广好微信朋友圈推广文案
  • 现在学做网站赚钱吗东莞市优速网络科技有限公司
  • 宁津做网站公司宣传推广图片
  • 陕西的建设厅官方网站数据分析报告
  • 企业网站建设的定位互联网
  • 注册域名之后如何做网站优化清理大师
  • wordpress+在线播放推广seo网站
  • 丽水网站建设明恩玉杰网站开发框架
  • 如何设计网站中的上传功能搜索引擎技术基础
  • 余江区建设局网站百度搜索引擎优化的方法
  • 做网站用c 还是java万网域名注册教程
  • 青岛做网站那家好专业的网站优化公司排名
  • 网站如何做淘宝推广seo服务 收费
  • 学完js了可以做哪些网站营业推广的形式包括
  • 网站会员系统怎么做模版seo是指什么职位
  • 上海集团网站制作新闻 近期大事件
  • 商城网站验收标准seo关键词排名优化怎样收费
  • 睢宁做网站公司珠海百度关键字优化
  • 临安市住房和建设局网站伊春seo
  • 天津百度做网站多少钱游戏代理平台哪个好