|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
- #include <stdio.h>
- #include <stdlib.h>
- #define MAXSIZE 100
- typedef int ElemType;
- typedef struct
- {
- ElemType *base;
- int front;
- int rear;
- }
- //初始化队
- void InitQueue(cycleQueue *q)
- {
- q->base=(ElemType *)malloc(MAXSIZE*sizeof(ElemType));
- if(!q->base)
- exit(0);
- q->front=q->rear=0;
- }
- //循环队列 入队
- void InsertQueue(cycleQueue *q,ElemType e)
- {
- if((q->rear+1)%MAXSIZE==q->front)//判断是否队满
- return;
- q->base[q->rear]=e;//这里就不理解了,只知道是复制
- q->rear=(q->rear+1)%MAXSIZE;//尾指针往后移一位
- }
- //出队
- void DeleteQueue(cycleQueue *q,ElemType *e)
- {
- if(q->rear==q->front)
- return;
- *e=q->base[q->front];
- q->front=(q->front+1)%MAXSIZE;
- }
- int main()
- {
-
- return 0;
- }
复制代码
//循环队列 入队
void InsertQueue(cycleQueue *q,ElemType e)
{
if((q->rear+1)%MAXSIZE==q->front)//判断是否队满
return;
q->base[q->rear]=e;//这里就不理解了,只知道是复制
q->rear=(q->rear+1)%MAXSIZE;//尾指针往后移一位
}
现在主要是入队这不是很明白,q->base[q->rear]这个是什么意思,是一个动态数组吗?
小甲鱼哪课讲的是动态数组的相关知识点呀
求大佬解答,谢谢!
跟动态数组无关,这里就是简单的数组赋值而已啊,q->rear就是一个整形而已
|
|