-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestList.c
More file actions
83 lines (73 loc) · 2.44 KB
/
TestList.c
File metadata and controls
83 lines (73 loc) · 2.44 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
// Filename TestList.c
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include "ListADT.h"
void menu(int *choice);
main()
{
int Apos;
ListElementType AnItem;
ListType AList;
int choice;
char ch;
do
{
menu(&choice);
switch(choice)
{
case 1: CreateList(&AList); //DHMIOYRGIA LISTAS
break;
case 2: do
{
printf("DWSE ARI8MO GIA EISAGWGH STH LISTA: ");
scanf("%d", &AnItem);
do {
printf("DWSE TH 8ESH META THN OPOIA 8A GINEI H EISAGWGH STOIXEIOY: ");
scanf("%d", &Apos);
} while (Apos<-1 || Apos>AList.Size-1);
Insert(&AList, AnItem, Apos); //EISAGWGH STOIXEIOY META TH 8ESH POS STH LISTA
printf("\nContinue Y/N: ");
do
{
scanf("%c", &ch);
} while (toupper(ch)!= 'N' && toupper(ch)!= 'Y');
} while (toupper(ch)!='N');
break;
case 3: TraverseList(AList); //DIASXISH LISTAS
break;
case 4: if (EmptyList(AList))
printf("Empty List\n");
else
{
do {
printf("DWSE TH 8ESH TOY STOIXEIOY GIA DIAGRAFH: ");
scanf("%d", &Apos);
} while (Apos<0 || Apos>AList.Size-1);
Delete(&AList,Apos); //DIAGRAFH STOIXEIOY STH 8ESH POS STH LISTA
}
break;
case 5: if (EmptyList(AList))
printf("Empty List\n");
else printf("Not an Empty List\n");
break;
}
} while (choice!=6);
return 0;
}
void menu(int *choice)
{
printf(" MENOY \n");
printf("-------------------------------------------------\n");
printf("1. Create List\n");
printf("2. Insert an element to List\n");
printf("3. Traverse List\n");
printf("4. Delete an element from the List\n");
printf("5. Check if List is empty\n");
printf("6. Telos\n");
printf("\nChoice 1-6 : ");
do
{
scanf("%d", choice);
} while (*choice<1 && *choice>6);
}