operate_queue.h
来自「数据结构课程设计报告,虽然好多地方都有」· C头文件 代码 · 共 69 行
H
69 行
#define MAXSIZE 50
/*=====================================*/
/*定义结构体 */
/*=====================================*/
typedef struct{
int data[MAXSIZE];
int front, rear;
}Queue;
/*=========================================*/
/*建立空队列 */
/*=========================================*/
void Emplty_Queue(Queue *q)
{
q->front=q->rear=-1; //置空
}
/*=========================================*/
/*插入元素 */
/*=========================================*/
void Insert_Queue(Queue *q, int scan_max)
{
int i, scan_x;
for(i=0; i<scan_max; i++)
{
printf("元素%d=",i+1);
scanf("%d",&scan_x);
/*修改尾指针 */
q->rear=(q->rear+1)%MAXSIZE;
q->data[q->rear]=scan_x;
}
}
/*=========================================*/
/*显示队列 */
/*=========================================*/
void Out_Queue(Queue *q)
{
int i=q->front+1;
for(; i<=q->rear; i++)
{
printf("%d\n",q->data[i]);
}
}
/*=========================================*/
/*出队列 */
/*=========================================*/
void Push_Queue(Queue *q)
{
int x;
if(q!=NULL)
{
/*修改头指针 */
q->front=(q->front+1)%MAXSIZE;
x=q->data[q->front];
printf("出队列的元素为[%d]\n",x);
}
else
printf("空栈\n");
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?