链表实现学生学籍管理系统文档格式.docx
- 文档编号:21293106
- 上传时间:2023-01-29
- 格式:DOCX
- 页数:36
- 大小:22.73KB
链表实现学生学籍管理系统文档格式.docx
《链表实现学生学籍管理系统文档格式.docx》由会员分享,可在线阅读,更多相关《链表实现学生学籍管理系统文档格式.docx(36页珍藏版)》请在冰豆网上搜索。
//统计成绩在某一区间内的人数
structstu*ch_ji_paixu(structstu*);
//按成绩排序,默认的是按总成绩排序
structs*shaixuan(structstu*);
//筛选符合条件的数据,得到符合条件的结构体数据的指针。
voidshuchu_shai(structs*);
//输出筛选出来的数据
voidfb_shu_shai(structs*);
//将筛选出来的数据输入到文件中
voidavrage(structstu*head,float*);
//计算平均成绩
voidfb_avrage(float*);
//将平均成绩放在文件的最后面
//建立学生结构体
structstu
{
charnum[N];
charname[M];
intch_ji[L];
structstu*next;
};
//建立一个链表,存放学生结构体的指针
structs
structstu*p;
structs*ps;
voidmain()
{
inti,n,x=1,k=0;
floata[L]={0};
structstu*head=NULL;
structs*shead=NULL;
charch;
while(x)
{system("
cls"
);
printf("
*******************************************************************************\n"
0---退出系统1---录入数据\n"
2---保存文件3---按成绩排序\n"
4---查看信息5---按学号排序\n"
6---统计人数7---按条件筛选\n"
8---查询信息9---显示筛选结果\n"
10---插入数据11---保存筛选结果\n"
12---删除数据13---计算平均成绩\n"
14---修改数据15---保存平均成绩\n"
16---按条件统计人数\n"
scanf("
%d"
&
n);
getchar();
//有啥作用
switch(n)
{
case0:
x=0;
break;
case1:
head=scanf_();
case2:
if(head==NULL||head->
next==NULL)
{
printf("
请先录入学生的数据!
"
getchar();
break;
}
else
fprint_(head);
case3:
head=ch_ji_paixu(head);
case4:
print_(head);
case5:
head=num_paixu(head);
是否显示排序结果Y/N?
ch=getchar();
getchar();
if(ch=='
y'
||ch=='
Y'
)
{
printf("
\n"
print_(head);
}
case6:
k=to_ji(head);
总共有%3d名学生"
k);
case7:
shead=shaixuan(head);
if(shead!
=NULL&
&
shead->
ps!
=NULL)
是否显示筛选结果Y/N?
ch=getchar();
if(ch=='
{
printf("
shuchu_shai(shead);
getchar();
}
case8:
chaxun(head);
case9:
if(head==NULL||head->
else
shuchu_shai(shead);
case10:
head=charu(head);
case11:
fb_shu_shai(shead);
case12:
head=shanchu(head);
case13:
avrage(head,a);
平均值计算成功!
\n是否显示平均成绩Y/N?
\n语文数学英语总成绩\n"
%-8.2f%-8.2f%-8.2f%-8.2f"
a[0],a[1],a[2],a[L-1]);
getchar();
case14:
xiugai(head);
case15:
fb_avrage(a);
平均值保存成功!
case16:
k=t_ji_tj(head);
if(k>
0)
符合条件的有%3d名学生!
elseif(k==0)
没有符合条件的学生!
elseif(k==-2)
default:
printf("
输入有误,请重新输入!
getchar();
break;
}
}
}
//输出单个的学生数据
voidprintf_(structstu*p0)
inti;
printf("
学号:
puts(p0->
num);
姓名:
name);
语文数学英语总成绩\n"
for(i=0;
i<
L;
i++)
%-8d"
p0->
ch_ji[i]);
//接收单个的学生数据,返回指针,
structstu*scanf1_()
inti,sum=0;
structstu*p0;
p0=(structstu*)malloc(sizeof(structstu));
请输入学生的学号:
gets(p0->
请输入学生的姓名:
请输入学生的三科成绩(语文、数学、英语):
L-1;
{
p0->
sum+=p0->
ch_ji[i];
getchar();
p0->
ch_ji[L-1]=sum;
returnp0;
//得到学生的数据,并放入到链表中
structstu*scanf_()
structstu*p1,*p2,*head;
inti,sum=0,n=0;
注意:
当学生学号为0时输入结束\n\n"
p1=(structstu*)malloc(sizeof(structstu));
/*得到学生信息*/
head=p2=p1;
do
{printf("
gets(p1->
if(strcmp(p1->
num,"
0"
)==0)
break;
for(i=0;
scanf("
p1->
sum+=p1->
p1->
sum=0;
p1=(structstu*)malloc(sizeof(structstu));
p2->
next=p1;
p2=p1;
n++;
}while
(1);
p1->
next=NULL;
成绩输入结束!
/*学生的数据被放在链表中*/
returnhead;
/*输出链表中的学生信息*/
voidprint_(structstu*head)
structstu*p1,*p2;
p1=p2=head;
while(p1->
next!
"
puts(p1->
printf("
p1->
p1=p2->
next;
/*用链表给学生排序*/
structstu*num_paixu(structstu*head)
structstu*p1,*p2,*p3,*p4,*p5,*p6,*p7;
intx=1;
for(p1=head;
=NULL;
p4=p1,p1=p1->
next)
p3=p1;
for(p2=p1->
next,p5=p7=p2;
p2->
p7=p2,p2=p2->
if(strcmp(p3->
num,p2->
num)>
{
p3=p2;
p5=p7;
}
if(p3!
=p1)
{
if(x&
p1==head)
p6=p1->
p1->
next=p3->
p3->
next=p6;
p5->
head=p3;
p1=p3;
else
p4->
next=p3;
排序成功!
//根据学生的学号查询学生的信息,并把学生的数据输出
voidchaxun(structstu*head)
chara[N];
structstu*p1;
请输入要查询的学号:
gets(a);
p1=head;
num,a)==0)
p1=p1->
if(p1->
没有找到学号为%s的学生!
a);
else
要查询的学生信息如下:
\n\n"
printf_(p1);
//将学生的数据插入到顺序排放的链表中,并且插入后也是顺序排放的。
structstu*charu(structstu*head)
structstu*p1,*p2,*p3;
p1=scanf1_();
p2=head;
p3=p2;
while((strcmp(p2->
num,p1->
num)<
0)&
p3=p2;
p2=p2->
if(p2==head)
next=head;
head=p1;
else
p3->
next=p2;
插入成功!
//删除数据
structstu*shanchu(structstu*head)
请输入要删除的学生的学号:
p2=p1;
num,a)!
=0)&
if(p2->
没有找到要删除的数据!
elseif(p2==head)
head=p2->
删除成功!
{
next=p2->
//修改学生的信息。
voidxiugai(structstu*head)
inti,k;
输入要修改的学生的学号"
没有要找的学生信息!
***********************************\n"
*0---放弃修改*\n"
*1---修改学号*\n"
*2---修改姓名*\n"
*3---修改成绩*\n"
*4---修改全部*\n"
k);
switch(k)
case0:
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 实现 学生 学籍 管理 系统
![提示](https://static.bdocx.com/images/bang_tan.gif)