-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
123 lines (117 loc) · 2.81 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
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "functions.h"
#include "ui.h"
#define BOOK_MAX 50
#define TITLE_MAX 50
#define AUTHOR_MAX 50
int main(void)
{
nodes *head = NULL; // null
int choser = 0;
char title[TITLE_MAX];
char author[AUTHOR_MAX];
int id = 0;
int is_lend = 0;
char name[50];
char date[50];
char time[50];
book books;
starts:
choser = 0;
utils();
while (!(choser == 1 || choser == 2 || choser == 3 || choser == 4 || choser == 5))
{
scanf("%d", &choser);
}
switch (choser)
{
case 1:
sub_1();
scanf("%s %s %d", books.title, books.author, &books.book_id);
books.this_lend = is_lend;
head = insertNode(head, books);
goto starts;
break;
case 2:
choser = 0;
sub_2();
while (!(choser == 1 || choser == 2 || choser == 3))
{
scanf("%d", &choser);
}
switch (choser)
{
case 1:
printf("Please enter your id: ");
scanf("%d", &id);
head = deleteNode(head, id);
printf("Compelete!\n");
goto starts;
break;
case 2:
printf("Please enter the book title: ");
scanf("%s", title);
head = deleteNodeName(head, title);
printf("Compelete!\n");
goto starts;
break;
case 3:
printf("Please enter the book author: ");
scanf("%s", author);
head = deleteNodeAuthor(head, author);
printf("Compelete!\n");
goto starts;
break;
default:
break;
}
break;
case 3:
choser = 0;
sub_3();
while (!(choser == 1 || choser == 2 || choser == 3 || choser == 4))
{
scanf("%d", &choser);
}
switch (choser)
{
case 1:
displayList(head);
goto starts;
break;
case 2:
printf("Please enter your book id: ");
scanf("%d", &id);
displayID(head, id);
goto starts;
break;
case 3:
printf("Please enter author");
scanf("%s", author);
displayAuthor(head, author);
goto starts;
break;
case 4:
printf("Please enter title");
scanf("%s", title);
displayTitle(head, title);
goto starts;
break;
default:
break;
}
break;
case 4:
choser = 0;
sub_4();
scanf("%s %d %s %s", name, &id, date, time);
changeLendStatus(head, id, name, date, time);
goto starts;
break;
case 5:
break;
}
return 0;
}