-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
359 lines (342 loc) · 7.74 KB
/
Copy pathmain.c
File metadata and controls
359 lines (342 loc) · 7.74 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
#include <stdio.h>
#include <stdlib.h>
#include "lesson.h"
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
//void ad();
LinkInfo L = NULL;
student* s =NULL;
int main(int argc, char *argv[]) {
int i;
system("color 2");
gotoxy(49,80);
printf("欢迎来到选课系统");
for(i=0;i<=15;i++){
printf("\n");
}
restart:;
menu();
int choice;
while(scanf("%d",&choice) != EOF){
fflush(stdin);
choice = (char)(choice+96);
switch(choice){
case 'a':{
student* t = (student*)malloc(sizeof(student));
int judge;
system("cls");
if(s == NULL){
createStudent(&s);
judge = StudentInform(s,t);
if(judge == 1){
printf("注册成功!\n");
menu();
}else if(judge == 0){
printf("密码不一致\n");
menu();
}else if(judge == 9){
printf("密码长度不能大于20\n");
menu();
}else if(judge == 8){
printf("该用户已存在\n");
menu();
}
}else{
judge = StudentInform(s,t);
if(judge == 1){
printf("注册成功!\n");
menu();
}else if(judge == 0){
printf("密码不一致\n");
menu();
}else if(judge == 9){
printf("密码长度不能大于20\n");
menu();
}else if(judge == 8){
printf("该用户已存在\n");
menu();
}
}
break;
}
case 'b': {
loginrst:;
int number,judge;
char password[20];
loginMenu();
scanf("%d",&number);
gotoxy(55,81);
scanf("%s",&password);
judge = CheckPassword(s,number,password);
if(judge ==6){
printf("该用户不存在\n");
goto restart;
}else if(judge == 10){
printf("密码错误\n");
goto restart;
}else if(judge == 2){
printf("还没有用户进行注册\n");
goto restart;
}else{
Userrst:;
UserMenu();
while(scanf("%d",&choice) != EOF){
fflush(stdin);
choice = (char)(choice+96);
switch(choice){
case 'a':{
int judge;
judge = checkTotalLesson(L);
if(judge == 1){
printf("查阅成功\n");
system("pause");
UserMenu();
}else{
printf("管理员还没有放置课程\n");
UserMenu();
}
break;
}
case 'b':{
int judge;
LesInfo* t = (LesInfo*)malloc(sizeof(LesInfo));
judge = PickLesson(s,L,t,number);
if(judge == 3){
printf("暂时未有课程可以选择\n");
}else if(judge == 5){
printf("该课程不存在");
}else if(judge == 1){
printf("选择成功");
}else if(judge == 7){
printf("该课程已经满人了\n");
}else if(judge == 11){
printf("不可以重复选择\n");
}else if(judge == 12){
printf("你已经不能选课了\n");
}
UserMenu();
break;
}
case 'c': {
int judge;
judge = DeleteChooseLesson(s,L,number);
if(judge == 3){
printf("暂时未有课程可以选择\n");
}else if(judge == 5){
printf("该课程不存在\n");
}else if(judge == 0){
printf("你并没有选择该课程\n");
}else if (judge == 1){
printf("删除成功\n");
}
UserMenu();
break;
}
case 'd':{
int judge;
judge = checkSelectLesson(s,L,number);
if(judge == 3){
printf("暂时未有课程发布\n");
}else if(judge == 0){
printf("你并没有选择课程\n");
}else if(judge == 1){
printf("查阅成功");
}
system("pause");
UserMenu();
break;
}
case 'e':{ //编号查找课程模块
int judge;
judge = FindLesson(L);
if(judge == 3){
printf("暂时未有课程发布\n");
}else if(judge == 5){
printf("该课程不存在\n");
}else if(judge == 1){
printf("查找成功\n");
system("pause");
}
UserMenu();
break;
}
case 'f':{
gotoxy(57,82);
Sleep(1000);
goto restart;
break;
}
default:{
gotoxy(57,82);
printf("输入错误,请重新输入!");
Sleep(1000);
goto Userrst;
break;
}
}
}
}
break;
}
case 'c':{
manageMenu();
int Adminchoice;
scanf("%d",&Adminchoice);
if(Adminchoice == 123){
Adminrst:;
AdminMenu();
while(scanf("%d",&choice) != EOF){
fflush(stdin);
choice = (char)(choice+96);
switch(choice){
case 'a':{
LinkInfo q = (LinkInfo)malloc(sizeof(LesInfo));
int judge;
if(L == NULL){
createSystem(&L);
judge = insertLesson(L,q);
if(judge == 1){
printf("插入成功");
AdminMenu();
}else if(judge == 0){
printf("插入失败");
AdminMenu();
}else if(judge ==4){
printf("该课程已存在");
AdminMenu();
}
}else{
judge = insertLesson(L,q);
if(judge == 1){
printf("插入成功");
AdminMenu();
}else if(judge == 0){
printf("插入失败");
AdminMenu();
}else if(judge == 4){
printf("该课程已存在");
AdminMenu();
}
}
break;
}
case 'b':{
int judge;
judge = DeleteLesson(L);
if(judge == 3){
printf("暂时未有课程\n");
AdminMenu();
}else if(judge == 5){
printf("该课程不存在\n");
AdminMenu();
}else if(judge == 1){
printf("删除成功\n");
AdminMenu();
}
break;
}
case 'c':{
int judge;
judge = checkTotalLesson(L);
if(judge == 1){
printf("成功\n");
system("pause");
AdminMenu();
}else{
printf("暂时未有课程\n");
AdminMenu();
}
break;
}
case 'd':{
int judge;
judge = showUser(s);
if(judge == 2){
printf("暂时没有用户注册\n");
}else if(judge == 1){
printf("查阅成功\n");
system("pause");
}
AdminMenu();
break;
}
case 'e':{
gotoxy(57,83);
goto restart;
break;
}
case 'f':{
int i,judge;
if(L == NULL){
LinkInfo q = (LinkInfo)malloc(sizeof(LesInfo));
createSystem(&L);
FILE* t = fopen("lessonInput.txt","r");
for(i = 0;i<3;i++){
LinkInfo q = (LinkInfo)malloc(sizeof(LesInfo));
judge = insertLessonF(L, q,t);
if(judge ==1){
printf("插入成功!\n");
}else if(judge ==4){
printf("该课程已经存在\n");
}
}
fclose(t);
}else{
FILE* t = fopen("lessonInput.txt","r");
for(i = 0;i<3;i++){
LinkInfo q = (LinkInfo)malloc(sizeof(LesInfo));
judge = insertLessonF(L, q,t);
if(judge ==1){
printf("插入成功!\n");
}else if(judge ==4){
printf("该课程已经存在\n");
}
}
fclose(t);
}
printf("课程已经全部插入\n");
AdminMenu();
break;
}
default:{
gotoxy(57,83);
printf("输入错误,请重新输入!");
Sleep(1000);
goto Adminrst;
break;
}
}
}
}else{
system("cls");
gotoxy(49,82);
printf("密码错误\n");
for(i=0;i<=15;i++){
printf("\n");
}
goto restart;
}
}
break;
case 'd':{
system("cls");
gotoxy(57,84);
printf("现在退出系统");
for(i=0;i<=15;i++){
printf("\n");
}
FILE * fp;
fp = fopen("lesson.txt","w");
Init_file(fp);
Sleep(2000);
return 0;
break;
}
default:gotoxy(57,84);
printf("输入错误,请重新输入!");
Sleep(1000);
goto restart;
break;
}
}
return 0;
}