//front指向佇列的隊頭元素,rear指向隊尾元素的下乙個。因為鏈式佇列有頭節點,順序佇列沒得頭節點
//為了判斷是否未滿,最後乙個空間不放元素
#include
#include
#define max 100
struct book
;typedef
struct node
sqqueue;
intis_empty_sqqueue
(sqqueue sq)
;int
is_full_sqqueue
(sqqueue sq)
;void
insert_sqqueue
(sqqueue *sq,
struct book data)
;void
print_sqqueue
(sqqueue sq)
;void
delete_sqqueue
(sqqueue *sq)
;void
menu
(void);
intmain
(void
)insert_sqqueue
(&sq,data);}
break
;case2:
print_sqqueue
(sq)
;break
;case3:
delete_sqqueue
(&sq)
;break
;case4:
ret =
is_empty_sqqueue
(sq);if
(ret ==1)
printf
("the sqqueue is empty\n");
else
printf
("the sqqueue is not empty\n");
break
;case5:
ret =
is_full_sqqueue
(sq);if
(ret ==1)
printf
("the sqqueue is full\n");
else
printf
("the sqqueue is not full\n");
break
;default
:break;}
}return0;
}void
delete_sqqueue
(sqqueue *sq)
sq->front++;}
void
menu
(void
)int
is_empty_sqqueue
(sqqueue sq)
intis_full_sqqueue
(sqqueue sq)
void
print_sqqueue
(sqqueue sq)
}void
insert_sqqueue
(sqqueue *sq,
struct book data)
sq->b[sq->rear]
= data;
sq->rear ++
;}
順序表的基本功能(C語言實現)
include include define maxsize 100 define true 1 define ok 1 define false 0 define error 0 define overflow 1 typedef int elemtype typedef int status t...
c語言實現鏈佇列的基本功能
鏈佇列,實際上是乙個帶有頭指標和尾指標的單鏈表,頭指標指向頭節點 不存放資料 尾指標指向隊尾節點,雖然用頭指標可以確定乙個單鏈表,但是插入操作是在隊尾進行,如果沒有尾指標,會變得複雜 初始化 void init pqueue pq 注意 1 為頭指標和尾指標申請記憶體 入隊 void enqueue...
C語言實現鏈式佇列的基本功能
rear指向隊尾部元素,front指向隊頭元素的前乙個 鏈式佇列相當與鍊錶很相似,有著頭指標和頭節點,傳引數也都是傳的指標,但是不同的是這裡的指標是結構體指標,可以看成二級指標 所以在列印等函式中需要有個中間變數,否則會改變front和rear的指向 include include struct b...