鏈式佇列簡單實現

2021-06-15 06:58:30 字數 1130 閱讀 7934

鏈式佇列的簡單實現,注釋我就不寫了.

queue.h

#ifndef queue_h

#define queue_h 1

typedef int int32;

typedef unsigned int uint32;

typedef unsigned char uchar8;

typedef char char8;

typedef long long int long64;

typedef unsigned long long int ulong64;

typedef double double64;

typedef float float32;

struct node

;typedef struct node *pnode;

struct link //指向頭和尾

;typedef struct link *plink;

plink create();

int32 empty(plink q);

void push(plink q,int32 data);

void pop(plink q);

int32 front(plink q);

#endif

queue.c

#include#include#include"queue.h"

plink create()

void push(plink q,int32 data)

else }

void pop(plink q)

q->head = q->head->next;

free(temp);

}int32 front(plink q)

int32 empty(plink q)

main.c

#include#include"queue.h"

int main()

while(empty(q) != 1)

printf("\n");

return 0;

}

佇列實現 迴圈佇列 鏈式佇列

佇列 queue 是一種類似棧的資料結構,棧是 後進先出 而佇列是 先進先出 佇列通常模擬進出一致的資料處理場景,例如訊息推送處理,中的購物處理等.迴圈佇列預備知識 鏈式佇列預備知識 include include define error 0 define ok 1 define true 1 d...

鏈式佇列的實現

typedef struct nodelinklist typedef structlinkqueue void setnull linkqueue p set a empty queue,front and rear pointer both point to a head node void q...

鏈式佇列的實現

include include define n 10 定義結點 typedef struct node node 定義佇列 typedef struct queue queue 判斷佇列是否為空 int empty queue queue 初始化佇列 queue init 入隊 int inque...