Me At MINERVA

Me At MINERVA

THE PHOENIX LEGION

THE PHOENIX LEGION

Facebook Badge

Friday, May 13, 2016

QUEUE

#include
#include
#include
using namespace std;
int a[5], f = -1, r = -1;
void insertion(void)
{
int n;
char s;
do{
cout << "enter a number \n";
cin >> n;
system("CLS");
if (r >= 5){
cout << "quene is full \n";
}
else{
a[++r] = n;
if (f == -1){
f = 0;
}
}
cout << "If you want to do more operation press y else n \n";

cin >> s;
} while (s == 'y');
}
void deletion(void)
{
char s;
do{
system("CLS");
if (f == -1){
cout << "quene is empty \n";
}
else{
a[f] = 0;
if (f == r){
f = r = -1;
}
else{
f++;
}
}
cout << "If you want to do more operation press y else n \n";
cin >> s;
} while (s == 'y');
}
void output()
{
if (f == 0)
{
for (int i = f; i <= r; i++)
{
cout << a[i] << endl;
}
}
else
{
cout << "quene is empty \n";
}
}
int main()
{
char s;
int x;
system("COLOR F0");
do{
system("CLS");
cout << "for insertion press 1 \n";
cout << "for deletion press 2 \n";
cout << "for output press 3 \n";
cin >> x;
switch (x){
case 1:{
insertion();
break; }
case 2:{
deletion();
break; }
case 3:{
output();
break; }
default:{
cout << "entry is an invalid number /n";
}
}
cout << "If you want to do more operation press y else n \n";
cin >> s;
} while (s == 'y');

return 0;
}

No comments:

Post a Comment