Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed the bug #2690 in data_structures/queue_using_array2.cpp #2694

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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