-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathban_process.c
170 lines (152 loc) · 3.78 KB
/
ban_process.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
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
#define __ban_process_c__
#include "ban_data.h"
#include "ban_process.h"
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
//----------班级基本信息的处理------------
//功能描述:调用相关的数据处理函数实现显示ban.txt中所有班级信息
//输入参数:本函数无参数
//返回值:无
void __disp_all_ban()
{
struct banji_list list={null,null};
if(read_ban(&list)<=0)
{
printf("无数据!\r\n");
return;
}
disp_ban_list(&list);
empty_ban_list(&list);
}
//功能描述:根据班级编号显示该班的信息
//输入参数:参数 ban_bh[]的参数类型为字符串数组,该参数用于存放用户输入的班级编号信息,值不可以为空
//返回值:无
void __disp_ban_bh(char ban_bh[])
{
struct banji_list list={null,null};
struct __banji *p;
if(ban_bh==null)
{
printf("错误:班号为空!\r\n");
return;
}
if(read_ban(&list)<=0)
{
printf("无数据!\r\n");
return;
}
if((p=get_ban_by_bh(&list,ban_bh))==null)
{
printf("找不到编号为%s的班级!\r\n",ban_bh);
}
else
{
printf("序号\t编号\t\t专业\t\t年级\t班号\r\n");
printf("1\t");
disp_ban(p);
printf("\r\n");
}
empty_ban_list(&list);
}
//功能描述:让用户在屏幕上输入信息,增加一个班
//输入参数:本函数无参数
//返回值:无
void __zengjia_ban()
{
struct banji_list list={null,null};
struct __banji *p=(struct __banji *)malloc(sizeof(struct __banji));
if(p==null)
{
printf("__zengjia_ban报告错误:无法申请内存!\r\n");
exit(0);
}
printf("增加班级:\r\n");
printf("\t请输入班级编号:");
scanf("%s",p->bianhao);
printf("\t请输入班级专业:");
scanf("%s",p->zhuanye);
printf("\t请输入班级年级:");
scanf("%s",p->nianji);
printf("\t请输入班级号:");
scanf("%s",p->banhao);
read_ban(&list);
add_ban_to_list(&list,p);
if(write_ban(&list)>0) printf("保存成功!\r\n");
empty_ban_list(&list);
}
//功能描述:根据班级号删除指定班级的信息
//输入参数:参数 ban_bh[]的参数类型为字符串数组,该参数用于存放用户输入的班级编号信息,值不可以为空
//返回值:无
void __shanchu_ban_bh(char ban_bh[])
{
char cmd[1024];
struct banji_list list={null,null};
struct __banji *p;
if(ban_bh==null)
{
printf("__shanchu_ban_bh报告错误:班级编号为空\r\n");
exit(0);
}
if(read_ban(&list)<=0)
{
printf("无数据!\r\n");
return;
}
if((p=getout_ban_by_bh(&list,ban_bh))==null)
{
printf("找不到编号为%s的班级!\r\n",ban_bh);
empty_ban_list(&list);
return;
}
printf("是否确认删除该班(Y/N):");
scanf("%s",cmd);
if(strcmp(cmd,"y") ==0||strcmp(cmd,"yes")==0)
write_ban(&list);
empty_ban_list(&list);
}
//功能描述:根据编号对班级进行排序
//输入参数:本函数无参数
//返回值:无
void __paixu_ban_bh()
{
struct banji_list list={null,null};
if(read_ban(&list)<=0)
{
printf("无数据!\r\n");
return;
}
sort_ban_bh(&list);
write_ban(&list);
empty_ban_list(&list);
}
//功能描述:根据专业对班级进行排序
//输入参数:本函数无参数
//返回值:无
void __paixu_ban_zy()
{
struct banji_list list={null,null};
if(read_ban(&list)<=0)
{
printf("无数据!\r\n");
return;
}
sort_ban_zy(&list);
write_ban(&list);
empty_ban_list(&list);
}
//功能描述:根据年级对班级进行排序
//输入参数:本函数无参数
//返回值:无
void __paixu_ban_nj()
{
struct banji_list list={null,null};
if(read_ban(&list)<=0)
{
printf("无数据!\r\n");
return;
}
sort_ban_nj(&list);
write_ban(&list);
empty_ban_list(&list);
}