-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path9.JOB_QUEUE.cpp
119 lines (106 loc) · 1.52 KB
/
9.JOB_QUEUE.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
//job queue job specification
#include<iostream>
#include<conio.h>
#include<string.h>
#define N 5
using namespace std;
class osqueue
{
private:
int q[N];
string info[N];
int front , rear;
int p;
public:
osqueue()
{
front = -1;
rear = -1;
}
void insertjob()
{
int n;
if(rear == N-1)
{
cout<<"queue full\n";
return;
}
else
{
cout<<"enter the job no : ";
cin>>n;
if(front==-1)
{
q[++rear]=n;
++front;
}
else
{
q[++rear]=n;
}
}
}
void deletejob()
{
if(rear==-1&&front==-1)
{
cout<<"queue is empty\n";
return;
}
if(front == rear+1)
{
cout<<"All jobs deleted\n";
return;
}
if(front==rear)
{
front=-1;
rear=-1;
}
q[front++];
cout<<"job deleted"<<endl;
}
void display()
{
int i;
p=0;
if(rear==-1||front==-1)
{
cout<<"queue is empty\n";
return;
}
for(i=front;i<=rear;i++)
{
cout<<"Job no : "<<q[i]<<endl;
}
}
};
main()
{
osqueue q1;
int op=-1;
while(op!=0)
{
cout<<"\n1.INSERT JOB ";
cout<<"\n2.DELETE JOB";
cout<<"\n3.DISPLAY";
cout<<"\n4.EXIT";
cout<<"\n\nEnter Choice : ";
cin>>op;
switch(op)
{
case 1:
q1.insertjob();
break;
case 2:
q1.deletejob();
break;
case 3:
q1.display();
break;
case 4:
op=0;
break;
}
}
}