-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
69 lines (61 loc) · 1.36 KB
/
main.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
#include "single_list.h"
#include <stdio.h>
int main(void) {
int c; /* count of number */
int n; /* inserted number */
List list;
List lt; /* list for merge */
int i;
int x;
/* list initial */
list = lstini();
i = 0;
/* down order */
/* printf("\tinput the number of elements: "); */
scanf("%d", &c);
/* printf("\tinput element(s): "); */
while (++i <= c) {
scanf("%d", &n);
lstins(list, i, n);
}
/* list insert */
/* printf("\tinput insert value: "); */
scanf("%d", &x);
/* printf("\tinput insert index: "); */
scanf("%d", &i);
lstins(list, i, x);
lstprt(list);
/* list delete */
/* printf("\tinput delete index: "); */
scanf("%d", &i);
lstdel(list, i);
lstprt(list);
/* list search */
/* printf("\tinput search value: "); */
scanf("%d", &x);
i = lstser(list, x);
if (i) {
printf("%d\n", i);
} else {
printf("Not found\n");
}
/* list inverse */
lstinv(list);
/* printf("\tinversed list: \n"); */
lstprt(list);
/* a new list, prepare for merge */
lt = lstini();
i = 0;
/* up order */
/* printf("\tinput the number of elements: "); */
scanf("%d", &c);
/* printf("\tinput element(s): "); */
while (++i <= c) {
scanf("%d", &n);
lstins(lt, i, n);
}
/* merge two list */
/* printf("\tmerged two list: "); */
lstmeg(list, lt);
lstprt(list);
}