数据结构学籍管理组织系统Word下载.docx
《数据结构学籍管理组织系统Word下载.docx》由会员分享,可在线阅读,更多相关《数据结构学籍管理组织系统Word下载.docx(19页珍藏版)》请在冰点文库上搜索。
4.设计过程
1.算法思想分析
根据设计要求,首先定义三个数组,分别存放学号、姓名、成绩.
typedefstructstud//学生信息结构
{
longnum;
charname[20];
floatscore;
}Stud;
然后编写函数,实现添加、查找、删除、排序、退出功能,对数组元素进行操作。
2.算法描述与实现
添加信息:
定义添加信息函数,将输入的信息添加到数组中:
voidinser(longb)
Node*last,*current,*p;
current=head;
while(current!
=NULL&
&
b>
current->
student.num){
last=current;
current=current->
next;
}
查找学生:
voidsearchname(char*s)//按姓名查找
Node*p=head;
intflag=0;
printf("
\n学号姓名成绩:
\n"
);
while(p!
=NULL)
if(strcmp(p->
student.name,s)==0)
%ld%s%f\n"
p->
student.num,p->
student.name,p->
student.score);
flag=1;
p=p->
continue;
elsep=p->
if(!
flag)printf("
没有找到相关信息"
voidfind(longb)//按姓名查找
b!
=p->
student.num)
p)printf("
Nofound\n"
else{
\n学号姓名成绩\n"
输出信息:
voidprint()
=NULL){
3.系统测试
1.菜单
用户运行程序后,显示如下所示菜单,用户根据菜单提示进行操作(如图2.1)。
图2.1
2.批量添加
用户选择批量添加学生信息功能进行批量添加,可连续添加,按0结束添加操作(如图2.2)。
图2.2
3.按学号查找学生
将学生信息录入之后,若想查找某个学生,用户可选择按学号查找学生信息(图2.3)。
图2.3
4.按姓名查找学生
将学生信息录入之后,若想查找某个学生,用户可选择按姓名查找学生信息(图2.4)。
图2.4
5.添加信息
用户可以在批量添加后在单个添加学生信息(图2.5)。
图2.5
6.按学号删除学生信息
用户可根据情况对已添加的学生信息进行删除,通过学号删除(图2.6)。
图2.6
7.排序输出
程序可以将已添加的学生按照成绩的降序排列输出(图2.7).
图2.7
8.退出
操作结束后按0退出程序(图2.8)。
图2.8
5.设计总结
通过一周的课程设计,我从中受益匪浅,使得我对数据结构这门课有了更深一步的认识。
在设计过程中,我们发现问题,解决问题,一同探讨问题,在老师的帮助下把问题一一解决。
在解决问题的过程中得到了成长,在与同学的合作过程中,我获益良多,提高了自己的团队合作能力和实际动手能力,在亲自动手的同时提升自己,锻炼自己。
通过这次设计,我深深的感受到了做系统是一件十分复杂周密的事情,不能有半点的疏忽,需要一个人有周密的思考能力,分析问题、处理问题的能力,还要有足够的耐心。
参考文献
《数据结构程序设计题典》李春葆等编清华大学出版社
《数据结构(C语言版)》黄国瑜叶乃菁编清华大学出版社
《数据结构课程设计》苏仕华等编机械工业出版社
附录:
源代码
#include<
stdio.h>
string.h>
stdlib.h>
typedefstructnode
Studstudent;
structnode*next;
}Node;
Node*head=NULL;
voidread(void);
voidinser(longb);
voidprint();
voidfind(longb);
voidsearchname(char*s);
Node*del(longn);
voidsort(intflag);
voidmenu();
voidmain()
charchoose;
intflag=1;
while(flag)
menu();
//调用功能菜单函数,显示菜单项。
请选择功能:
"
choose=getchar();
switch(choose)
case'
1'
:
read();
//调用建立链表的函数;
输出链表信息;
print();
\nPressanykeyContinue"
getchar();
break;
2'
//调用按学号查找学生信息的函数;
并输出查找结果信息;
longc;
输入要查找的学号:
scanf("
%ld"
&
c);
find(c);
\nPressanykeyContinue."
3'
//调用按姓名查找学生信息的函数;
chars[20];
输入要查找的姓名:
%s"
s);
searchname(s);
\nPressanykeyContinue."
4'
//调用根据学号删除某个学生信息的函数;
并输出删除后的链表信息;
Node*h;
longn;
输入要删除的学生学号:
n);
h=del(n);
if(h==NULL)printf("
Nofindthestudent\n"
elseprint();
5'
//调用插入新的学生信息的函数;
并输出插入后的链表信息;
longa;
输入新学号:
a);
inser(a);
6'
//调用按分数降序排序输出的函数;
并输出排序后的链表信息;
sort
(1);
sort(0);
0'
//结束程序运行
flag=0;
\n***TheEnd!
***\n"
default:
printf("
\nWrongSelection!
(选择错误,重选)\n"
voidmenu()//综合作业功能菜单
\n学生信息管理系统\n"
\n*******************************菜单**********************************\n\n"
**********************************************************************\n\n"
*1.批量添加学生信息"
2.按学号查找学生信息*\n"
*3.按姓名查学生信息"
4.按学号删除学生信息*\n"
*5.录入新的学生信息"
6.按分数降序排序输出*\n"
----------0.返回-----------\n"
\
**********************************************************************\n"
voidread(void)
请输入学号:
while(a>
0){
if(current==NULL||b<
请输入姓名、分数:
p=(Node*)malloc(sizeof(Node));
p->
student.num=b;
%s%f"
student.name,&
next=NULL;
if(current==head){
next=head;
head=p;
else{
next=current;
last->
next=p;
elseif(b==current->
errorinputadifferentnumber:
voidfind(longb)
voidsearchname(char*s)
Node*del(longn)
Node*p=head,*last;
while(p->
student.num!
=n){
last=p;
if(p==NULL)returnp;
elseif(p==head)head=p->
elselast->
next=p->
returnhead;
voidsort(intflag)
{
Node*p1,*p2,*k;
floatt1;
longt2;
for(p1=head;
p1->
p1=p1->
next)
k=p1;
for(p2=p1->
p2;
p2=p2->
if(flag==1&
k->
student.score<
p2->
student.score||!
flag&
student.num>
k=p2;
if(k!
=p1){
t1=p1->
student.score;
student.score=k->
student.score=t1;
t2=p1->
student.num;
student.num=k->
student.num=t2;
strcpy(s,p1->
student.name);
strcpy(p1->
student.name,k->
strcpy(k->
student.name,s);
}