From c2eb1dbc5a9997e683f8b1d89dbabc4e470afa51 Mon Sep 17 00:00:00 2001 From: Kunchen-Luo <247349913+Kunchen-Luo@users.noreply.github.com> Date: Mon, 30 Mar 2026 14:46:56 +0800 Subject: [PATCH] Fix confusion between queSize and rear pointer in ArrayQueue implementation (#1851) - `queSize` represents the queue's size, not the rear pointer position. - In `pop`, `queSize--` decreases the size, not the rear pointer. - The rear pointer is calculated using modulo (`%`) with the `front` and `queSize` to avoid confusion. Co-authored-by: Chance Luo <247349913+chanceluo1618-bot@users.noreply.github.com> --- codes/c/chapter_stack_and_queue/array_queue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codes/c/chapter_stack_and_queue/array_queue.c b/codes/c/chapter_stack_and_queue/array_queue.c index ad6f4fb27..773510a0d 100644 --- a/codes/c/chapter_stack_and_queue/array_queue.c +++ b/codes/c/chapter_stack_and_queue/array_queue.c @@ -10,7 +10,7 @@ typedef struct { int *nums; // 用于存储队列元素的数组 int front; // 队首指针,指向队首元素 - int queSize; // 尾指针,指向队尾 + 1 + int queSize; // 当前队列的元素数量 int queCapacity; // 队列容量 } ArrayQueue;