#include <stdio.h>
#include <stdlib.h>
#define MAXSIZE 10
typedef struct Queue {
int data_queue[MAXSIZE];
int front;
int rear;
}Queue;
void Init_Queue(Queue* );
void enqueue(Queue* , int );
void dequeue(Queue*, int*);
void print_queue(Queue* );
int main() {
Queue queue1;
int getvalue = 0;
Init_Queue(&queue1);//队列初始化
print_queue(&queue1);//输出队列
for (int k = 0; k < 10; k++) { /*入队*/
enqueue(&queue1, 10 * k + 10);
}
print_queue(&queue1);//输出队列
dequeue(&queue1, &getvalue);
return 0;
}
void Init_Queue(Queue* input_queue )
{
input_queue->front = -1;
input_queue->rear = -1;
}
/*入队*/
void enqueue(Queue* input_queue,int intput_value){
input_queue->front++;
input_queue->data_queue[(input_queue->front)] = intput_value;//
}
/*出队*/
void dequeue(Queue* input_queue, int* p_getvalue) {
*p_getvalue = input_queue->data_queue[input_queue->rear];
input_queue->rear++;
}
void print_queue(Queue* input_queue) {
int search = input_queue->rear + 1;
if (input_queue->rear == input_queue->front) {
printf("队列为空队列\n");
return;
}
while (search != input_queue->front + 1) {
printf("queue[ ]=%d\n", input_queue->data_queue[search]);
search++;
}
}