Skip to content

Commit

Permalink
fixed the bug TheAlgorithms#2690 in data_structures/queue_using_array…
Browse files Browse the repository at this point in the history
…2.cpp
  • Loading branch information
RushinShah22 committed May 4, 2024
1 parent 2dadbf7 commit 4bb56d1
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions data_structures/queue_using_array2.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#include <iostream>
using namespace std;

int queue[10];
int arr[10];
int front = 0;
int rear = 0;

void Enque(int x) {
if (rear == 10) {
cout << "\nOverflow";
} else {
queue[rear++] = x;
arr[rear++] = x;
}
}

Expand All @@ -19,9 +19,9 @@ void Deque() {
}

else {
cout << "\n" << queue[front++] << " deleted";
cout << "\n" << arr[front++] << " deleted";
for (int i = front; i < rear; i++) {
queue[i - front] = queue[i];
arr[i - front] = arr[i];
}
rear = rear - front;
front = 0;
Expand All @@ -30,7 +30,7 @@ void Deque() {

void show() {
for (int i = front; i < rear; i++) {
cout << queue[i] << "\t";
cout << arr[i] << "\t";
}
}

Expand Down

0 comments on commit 4bb56d1

Please sign in to comment.