-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCall_Center.c
94 lines (94 loc) · 2.58 KB
/
Call_Center.c
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
#include<conio.h>
#include"processed_queue.h"
#include"time.h"
void message(char *msg){
int c=0;
while(1){
printf("\n");
printf(msg);
delay(1);
printf(".");
delay(1);
printf(".");
delay(1);
printf(".");
delay(1);
printf("\33[2K\033[A\r");
if(c==1)
break;
c++;
}
}
int main(){
run();
printf("--------------------WELCOME--------------------\n");
if(isfull()){
printf("THE QUEUE IS FULL\n");
}
else{
if(count!=0)
display();
printf("\nTHERE ARE %d CALLER(S) IN QUEUE\n",count);
}
int choice;
printf("DO YOU WANT TO GO ON CALL? (1-YES 0-NO): ");
scanf("%d",&choice);
if(choice==0){
printf("THANK YOU FOR YOUR TIME!");
exit(0);
}
if(isfull()){
printf("\nALL OPEARTORS ARE BUSY!\nWE ARE SORRY FOR THE INCONVENIENCE!\nPLEASE WAIT:\n");
printf("\n%d CALLER(S) REMAINING! WAIT FOR A SLOT!\n",count);
display();
message("WAIT");
dequeue();
printf("\n%d CALLER(S) REMAINING BEFORE YOU\n",count);
display();
goto label;
}
else{
int ans;
label:
if(count>0){
printf("\nIS THE CALL AN EMERGENCY (1-YES, 0-NO):\n");
scanf("%d",&ans);
}
else{
ans=1;
}
if(ans==1){
printf("\nYOU HAVE BEEN SKIPPED TO THE FRONT OF THE QUEUE");
queue[(rear+1)%N].priority=1;
enqueue(2);
printf("\nYOU ARE ON THE CALL!\n");
display();
printf("\nPLEASE TALK!");
for(int i=0;i<3;i++)
message("TALKING");
printf("\nTHE CALL HAS ENDED");
printf("\nTHANK YOU FOR YOUR TIME!");
}
else{
enqueue(2);
int temp_count=count;
while(queue[front].item!=2){
printf("\n%d CALLER(S) REMAINING BEFORE YOU\n",--temp_count);
display();
message("WAIT");
dequeue();
for(int i=0;i<N+1-count;i++)
enqueue(1);
}
printf("\n");
printf("\nYOU ARE ON THE CALL!\n");
display();
printf("\nPLEASE TALK!");
for(int i=0;i<3;i++)
message("TALKING");
printf("\nTHE CALL HAS ENDED");
printf("\nTHANK YOU FOR YOUR TIME!");
}
}
return 0;
}