-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestQueue.c
More file actions
92 lines (85 loc) · 2.51 KB
/
TestQueue.c
File metadata and controls
92 lines (85 loc) · 2.51 KB
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
//filename TestQueue.c
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include "QueueADT.h"
void menu(int *choice);
void TraverseQ(QueueType Queue);
main()
{
QueueType AQueue;
int choice;
QueueElementType AnItem;
do
{
menu(&choice);
switch(choice)
{
case 1: CreateQ(&AQueue);
break;
case 2: if (EmptyQ(AQueue))
printf("Empty Queue...\n");
else
while (!EmptyQ(AQueue))
{
RemoveQ(&AQueue, &AnItem);
printf("KORYFAIO STOIXEIO %d\n",AnItem);
}
break;
case 3: if (EmptyQ(AQueue))
printf("Empty Queue\n");
else printf("Not an Empty Queue\n");
break;
case 4: if (EmptyQ(AQueue))
printf("Empty Queue\n");
else {
RemoveQ(&AQueue, &AnItem);
printf("KORYFAIO STOIXEIO %d\n",AnItem);
}
break;
case 5: printf("DWSE STOIXEIO GIA EIGWGH: ");
scanf("%d",&AnItem);
AddQ(&AQueue,AnItem);
break;
case 6: if (EmptyQ(AQueue))
printf("Empty Queue...\n");
else TraverseQ(AQueue);
break;
}
} while (choice!=7);
return 0;
}
void menu(int *choice)
{
printf(" MENOY \n");
printf("-------------------------------------------------\n");
printf("1 ---- DHMIOYRGIA OURAS\n");
printf("2 ---- ADEIASMA THS OYRAS\n");
printf("3 ---- ELEGXOS KENHS OYRAS\n");
printf("4 --- DIAGRAFH STOIXEIOY APO TH KORYFH THS OYRAS\n");
printf("5 --- PROS8HKH STOIXEIOY STO TELOS THS OYRAS\n");
printf("6 ---- EMFANISH STOIXEIWN OURAS (BOH8HTHKH)\n");
printf("7 ---- EXIT\n");
printf("\nChoice: ");
do
{
scanf("%d", choice);
} while (*choice<1 && *choice>7);
}
void TraverseQ(QueueType Queue)
{
QueuePointer CurrPtr;
if (EmptyQ(Queue))
{
printf("EMPTY Queue\n");
}
else
{
CurrPtr = Queue.Front;
while ( CurrPtr!=NULL )
{
printf("%d\n", CurrPtr->Data);
CurrPtr = CurrPtr->Next;
}
}
}