# 数据结构链式队列

1.入队列

2.出队列

3.取队首元素

//不带头结点的不带环的单向链式队列
#pragma once
#include<stdio.h>
#include<stddef.h>
#include<stdlib.h>
void LQPrintChar(LinkQueue* queue, const char* msg);//打印函数

if (queue == NULL){
return;
}
queue->tail = NULL;
}
void LQPrintChar(LinkQueue* queue, const char* msg){
if (queue == NULL){
return;
}
printf("%s\n", msg);
printf("队首 ");
for (; cur != NULL; cur = cur->next){
printf("[%c] ", cur->data);
}
printf(" 队尾\n");
}
newnode->data = value;
newnode->next = NULL;
return newnode;
}
free(queue->tail);
}
if (queue == NULL){
return NULL;
}
//空队列
}
queue->tail->next = newnode;
queue->tail = queue->tail->next;
}
if (queue == NULL){
return;
}
//空队列
return;
}
}
if (queue == NULL||value==NULL){
return 0;
}
//空队列
return 0;
}
return 1;

}

test.c

void TestInit(){
LQPrintChar(&queue,"初始化函数");
}
void TestPush(){
LQPrintChar(&queue, "入队列四个元素");
printf("expect ret is 1,actual is %d\n", ret);
printf("expect value is a,actual is %c\n", value);
printf("\n");

LQPrintChar(&queue, "出队列两个元素");
printf("expect ret is 1,actual is %d\n", ret);
printf("expect value is c,actual is %c\n", value);
printf("\n");

LQPrintChar(&queue, "再出队列两个元素");
printf("expect ret is 0,actual is %d\n", ret);
printf("\n");

LQPrintChar(&queue, "尝试对空队列删除元素");
printf("expect ret is 0,actual is %d\n", ret);
printf("\n");

}
int main(){
TestInit();
TestPush();
getchar();
return 0;
}

• 广告
• 抄袭
• 版权
• 政治
• 色情
• 无意义
• 其他

120