mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-02-09 13:37:25 +08:00
style: format code
This commit is contained in:
@@ -1,47 +1,46 @@
|
||||
#include<iostream>
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
int queue[10];
|
||||
int front=0;
|
||||
int rear=0;
|
||||
int count=0;
|
||||
int front = 0;
|
||||
int rear = 0;
|
||||
int count = 0;
|
||||
|
||||
void Enque(int x)
|
||||
{
|
||||
if(count==10)
|
||||
if (count == 10)
|
||||
{
|
||||
cout<<"\nOverflow";
|
||||
cout << "\nOverflow";
|
||||
}
|
||||
else
|
||||
{
|
||||
queue[rear]=x;
|
||||
rear=(rear+1)%10;
|
||||
queue[rear] = x;
|
||||
rear = (rear + 1) % 10;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
void Deque()
|
||||
{
|
||||
if (front==rear)
|
||||
if (front == rear)
|
||||
{
|
||||
cout<<"\nUnderflow";
|
||||
cout << "\nUnderflow";
|
||||
}
|
||||
|
||||
|
||||
else
|
||||
{
|
||||
cout<<"\n"<<queue[front]<<" deleted";
|
||||
front=(front+1)%10;
|
||||
cout << "\n"
|
||||
<< queue[front] << " deleted";
|
||||
front = (front + 1) % 10;
|
||||
count--;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void show()
|
||||
{
|
||||
for (int i = 0; i<count; i++)
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
cout<<queue[(i+front)%10]<<"\t";
|
||||
cout << queue[(i + front) % 10] << "\t";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,28 +49,26 @@ int main()
|
||||
int ch, x;
|
||||
do
|
||||
{
|
||||
cout<<"\n1. Enque";
|
||||
cout<<"\n2. Deque";
|
||||
cout<<"\n3. Print";
|
||||
cout<<"\nEnter Your Choice : ";
|
||||
cin>>ch;
|
||||
if (ch==1)
|
||||
cout << "\n1. Enque";
|
||||
cout << "\n2. Deque";
|
||||
cout << "\n3. Print";
|
||||
cout << "\nEnter Your Choice : ";
|
||||
cin >> ch;
|
||||
if (ch == 1)
|
||||
{
|
||||
cout<<"\nInsert : ";
|
||||
cin>>x;
|
||||
cout << "\nInsert : ";
|
||||
cin >> x;
|
||||
Enque(x);
|
||||
}
|
||||
else if (ch==2)
|
||||
else if (ch == 2)
|
||||
{
|
||||
Deque();
|
||||
}
|
||||
else if (ch==3)
|
||||
else if (ch == 3)
|
||||
{
|
||||
show();
|
||||
}
|
||||
}
|
||||
while(ch!=0);
|
||||
} while (ch != 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user