Skip to content

fix: namespace clashing in queue.cpp #2751

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

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 12 additions & 13 deletions data_structures/queue_using_array2.cpp
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
#include <iostream>
using namespace std;

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

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

void Deque() {
if (front == rear) {
cout << "\nUnderflow";
std::cout << "\nUnderflow";
}

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

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

int main() {
int ch, x;
do {
cout << "\n1. Enque";
cout << "\n2. Deque";
cout << "\n3. Print";
cout << "\nEnter Your Choice : ";
cin >> ch;
std::cout << "\n1. Enque";
std::cout << "\n2. Deque";
std::cout << "\n3. Print";
std::cout << "\nEnter Your Choice : ";
std::cin >> ch;
if (ch == 1) {
cout << "\nInsert : ";
cin >> x;
std::cout << "\nInsert : ";
std::cin >> x;
Enque(x);
} else if (ch == 2) {
Deque();
Expand All @@ -54,4 +53,4 @@ int main() {
} while (ch != 0);

return 0;
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}
}

Loading