C??????????????????????????
????????????????? ???????[ 2016/9/30 11:03:42 ] ????????C???? ????
?????????????????C?????????t???????????????С??????????t?????????????е????????????????С?????????????????????????????????????У????????????????????????????????????????????????????????????????????????????????????????????????? https://github.com/chenyufeng1991/Queue_DynamicArray ??
??????1??????????
????static int *queue;//????????
????static int maxSize;//?????С
????static int head;//??????
????static int tail;//???β??
??????2???????????
????//?????????
????void InitQueue(int size){
????maxSize = size;
????queue = (int *)malloc(size * sizeof(int));
????head = 0;
????tail = 0;
????}
??????3????????
????//??????
????void EnQueue(int value){
????//???ж????????
????if ((tail + 1) % maxSize == head) {
????printf("?????????????????
");
????}else{
????//δ??
????queue[tail] = value;
????tail = (tail + 1) % maxSize;
????}
????}
??????4????????
????//??????
????int DeQueue(){
????int temp;
????//???ж???????
????if (head == tail) {
????printf("???????????????
");
????}else{
????temp = head;
????head = (head + 1) % maxSize;
????}
????return temp;
????}
??????5???ж??????????
????//?ж??????????
????int IsEmpty(){
????if (head == tail) {
????printf("???????
");
????return 1;
????}
????printf("???в????
");
????return 0;
????}
??????6???ж???????????
????//?ж???????????
????int IsFull(){
????if ((tail + 1)% maxSize == head) {
????printf("????????
");
????return 1;
????}
????printf("????δ??
");
????return 0;
????}
??????7????????????
????//??????????
????void PrintQueue(){
????for (int i = head; i < tail; i++) {
????printf("%d "??queue[i]);
????}
????printf("
");
????}
??????8?????????
????int main(int argc?? const char * argv[]) {
????InitQueue(5);
????EnQueue(2);EnQueue(4);EnQueue(8);EnQueue(1);EnQueue(5);
????PrintQueue();
????DeQueue();DeQueue();DeQueue();
????PrintQueue();
????IsEmpty();
????IsFull();
????return 0;
????}
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11