Skip to content
Snippets Groups Projects
Commit 166fc852 authored by yassin.elhakoun's avatar yassin.elhakoun
Browse files

Update cours_11.md (Modif du modulo dans l'égalité pour éviter des erreurs arrivé en fin de queue)

parent b60a03b4
No related branches found
No related tags found
No related merge requests found
Pipeline #27221 failed
...@@ -584,7 +584,7 @@ typedef struct _queue { ...@@ -584,7 +584,7 @@ typedef struct _queue {
```C ```C
void queue_enqueue(queue *fa, int val) { void queue_enqueue(queue *fa, int val) {
if ((fa->head == 0 && fa->tail == fa->capacity-1) || if ((fa->head == 0 && fa->tail == fa->capacity-1) ||
(fa->tail == (fa->head-1) % (fa->capacity-1))) { (fa->tail == (fa->head - 1 + fa->capacity) % fa->capacity) {
return; // queue is full return; // queue is full
} }
if (fa->head == -1) { // queue was empty if (fa->head == -1) { // queue was empty
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment