-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestPList.c
More file actions
102 lines (94 loc) · 3.02 KB
/
TestPList.c
File metadata and controls
102 lines (94 loc) · 3.02 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
93
94
95
96
97
98
99
100
101
102
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <conio.h>
#include "ListPADT.h"
void menu(int *choice);
void list_insertion(ListPointer *List, int choice1);
main()
{
ListPointer AList, PredPtr;
int choice, choice1;
ListElementType keyvalue;
boolean Found;
CreateList(&AList);
printf("ORDER OR ANORDER LIST (1 OR 2) ");
scanf("%d", &choice1);
do
{
menu(&choice);
switch(choice)
{
case 1: printf("main: &AList %7d, AList %7d\n",&AList, AList);
list_insertion(&AList, choice1);
printf("&AList %7d, AList %7d\n",&AList, AList);
break;
case 2: LinkedTraverse(AList);
getch();
break;
case 3: printf("Enter Data for searching: "); scanf("%d", &keyvalue);
LinearSearch(AList, keyvalue, &PredPtr, &Found);
if ( Found )
printf("Found IN NODE \n");
else
printf("Item NOT IN LIST\n");
getch();
break;
case 4: printf("Enter Data for deleting: "); scanf("%d", &keyvalue);
LinearSearch(AList, keyvalue, &PredPtr, &Found);
if (Found)
LinkedDelete(&AList, PredPtr);
else
printf("Item NOT IN LIST\n");
getch();
break;
case 5: printf("Enter Data for searching: "); scanf("%d", &keyvalue);
OrderedLimearSearch(AList, keyvalue, &PredPtr, &Found);
if ( Found )
printf("Found IN NODE \n");
else
printf("Item NOT IN LIST\n");
getch();
break;
}
} while (choice!=6);
return 0;
}
void menu(int *choice)
{
printf(" MENOY \n");
printf("-------------------------------------------------\n");
printf("1. Eisagwgh stoixeiwn sth lista\n");
printf("2. Diasxish stoixeiwn ths listas\n");
printf("3. Anazhthsh stoixeiou sth lista\n");
printf("4. Diagrafh stoixeiou apo th lista\n");
printf("5. Anazhthsh stoixeiou se ordered lista\n");
printf("6. Telos\n");
printf("\nEpilogh: ");
do
{
scanf("%d", choice);
} while (*choice<1 && *choice>6);
}
void list_insertion(ListPointer *List,int choice1)
{
ListElementType Item;
char ch;
ListPointer PredPtr;
boolean Found;
do
{
printf("Enter a number for insertion in the list: "); scanf("%d", &Item);
if (choice1==1)
OrderedLimearSearch(*List, Item, &PredPtr, &Found);
else
PredPtr= NULL;
LinkedInsert(List, Item, PredPtr);
// printf("&List %7d, List %7d, *List %7d\n",&List, List, *List);
printf("\nContinue Y/N: ");
do
{
scanf("%c", &ch);
} while (toupper(ch)!= 'N' && toupper(ch)!= 'Y');
} while (toupper(ch)!='N');
}