数据结构学籍管理组织系统.docx

上传人:b****2 文档编号:3374480 上传时间:2023-05-05 格式:DOCX 页数:19 大小:132.90KB
下载 相关 举报
数据结构学籍管理组织系统.docx_第1页
第1页 / 共19页
数据结构学籍管理组织系统.docx_第2页
第2页 / 共19页
数据结构学籍管理组织系统.docx_第3页
第3页 / 共19页
数据结构学籍管理组织系统.docx_第4页
第4页 / 共19页
数据结构学籍管理组织系统.docx_第5页
第5页 / 共19页
数据结构学籍管理组织系统.docx_第6页
第6页 / 共19页
数据结构学籍管理组织系统.docx_第7页
第7页 / 共19页
数据结构学籍管理组织系统.docx_第8页
第8页 / 共19页
数据结构学籍管理组织系统.docx_第9页
第9页 / 共19页
数据结构学籍管理组织系统.docx_第10页
第10页 / 共19页
数据结构学籍管理组织系统.docx_第11页
第11页 / 共19页
数据结构学籍管理组织系统.docx_第12页
第12页 / 共19页
数据结构学籍管理组织系统.docx_第13页
第13页 / 共19页
数据结构学籍管理组织系统.docx_第14页
第14页 / 共19页
数据结构学籍管理组织系统.docx_第15页
第15页 / 共19页
数据结构学籍管理组织系统.docx_第16页
第16页 / 共19页
数据结构学籍管理组织系统.docx_第17页
第17页 / 共19页
数据结构学籍管理组织系统.docx_第18页
第18页 / 共19页
数据结构学籍管理组织系统.docx_第19页
第19页 / 共19页
亲,该文档总共19页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

数据结构学籍管理组织系统.docx

《数据结构学籍管理组织系统.docx》由会员分享,可在线阅读,更多相关《数据结构学籍管理组织系统.docx(19页珍藏版)》请在冰点文库上搜索。

数据结构学籍管理组织系统.docx

数据结构学籍管理组织系统

 

1.设计目的

 

1.了解并掌握数据结构与算法的设计方法,具备初步的独立分析和设计能力;

2.初步掌握软件开发过程的问题分析、系统设计、程序编码、测试等基本方法和技能;

 

3.提高综合运用所学的理论知识和方法独立分析和解决问题的能力;

 

4.训练用系统的观点和软件开发一般规范进行软件开发,培养软件工作者所应具备的科学的工作方法和作风。

 

2.设计内容

2.1开发环境

操作系统:

Windows7

开发工具:

MicrosoftVisualC++6.0

开发语言:

C++

2.2功能简介:

本程序采用C++编写,用于管理学生信息,基本功能有批量添加学生信息,单个添加学生信息,按学号查找学生,按姓名查找学生,按学号删除学生信息,排序输出全部学生信息以及退出功能。

程序流程:

 

 

3.设计要求

1)程序设计要求:

①采用交互工作方式,设计功能菜单;

②建立数据文件,数据包含学生的自然信息和成绩信息(设计几门课以及总成绩);

③对如下关键字:

姓名、学号、各科成绩进行排序(冒泡、选择、插入排序等任选一种)。

2)用二分查找实现如下查询:

①按姓名查询

②按学号查询

3)用堆排序找出总成绩排名的前5名学生

4)输出任一查询结果(可以连续操作)

 

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)

{

printf("%ld%s%f\n",p->student.num,p->student.name,p->student.score);

flag=1;

p=p->next;

continue;

}

elsep=p->next;

}

if(!

flag)printf("没有找到相关信息");

}

 

voidfind(longb)//按姓名查找

{

Node*p=head;

while(p!

=NULL&&b!

=p->student.num)

p=p->next;

if(!

p)printf("Nofound\n");

else{

printf("\n学号姓名成绩\n");

printf("%ld%s%f\n",p->student.num,p->student.name,p->student.score);

}

}

 

输出信息:

voidprint()

{

Node*p=head;

printf("\n学号姓名成绩:

\n");

while(p!

=NULL){

printf("%ld%s%f\n",p->student.num,p->student.name,p->student.score);

p=p->next;

}

printf("\n");

}

 

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

#include

#include

typedefstructstud//学生信息结构

{

longnum;

charname[20];

floatscore;

}Stud;

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();//调用功能菜单函数,显示菜单项。

printf("请选择功能:

");

choose=getchar();

switch(choose)

{

case'1':

read();//调用建立链表的函数;输出链表信息;

print();

printf("\nPressanykeyContinue");

getchar();

break;

case'2':

//调用按学号查找学生信息的函数;并输出查找结果信息;

longc;

printf("输入要查找的学号:

");

scanf("%ld",&c);

find(c);

printf("\nPressanykeyContinue.");

getchar();

break;

case'3':

//调用按姓名查找学生信息的函数;并输出查找结果信息;

chars[20];

printf("输入要查找的姓名:

");

scanf("%s",s);

searchname(s);

printf("\nPressanykeyContinue.");

getchar();

getchar();

break;

case'4':

//调用根据学号删除某个学生信息的函数;并输出删除后的链表信息;

Node*h;

longn;

printf("输入要删除的学生学号:

");

scanf("%ld",&n);

h=del(n);

if(h==NULL)printf("Nofindthestudent\n");

elseprint();

printf("\nPressanykeyContinue.");

getchar();

getchar();

break;

case'5':

//调用插入新的学生信息的函数;并输出插入后的链表信息;

longa;

printf("输入新学号:

\n");

scanf("%ld",&a);

inser(a);

print();

printf("\nPressanykeyContinue.");

getchar();

getchar();

break;

case'6':

//调用按分数降序排序输出的函数;并输出排序后的链表信息;

sort

(1);

print();

sort(0);

printf("\nPressanykeyContinue.");

getchar();

getchar();

break;

case'0':

//结束程序运行

flag=0;

printf("\n***TheEnd!

***\n");

break;

default:

printf("\nWrongSelection!

(选择错误,重选)\n");

getchar();

}

}

}

voidmenu()//综合作业功能菜单

{

printf("\n学生信息管理系统\n");

printf("\n*******************************菜单**********************************\n\n");

printf("**********************************************************************\n\n");

printf("*1.批量添加学生信息");

printf("2.按学号查找学生信息*\n");

printf("*3.按姓名查学生信息");

printf("4.按学号删除学生信息*\n");

printf("*5.录入新的学生信息");

printf("6.按分数降序排序输出*\n");

printf("----------0.返回-----------\n");\

printf("**********************************************************************\n");

}

voidread(void)

{

longa;

printf("请输入学号:

");

scanf("%ld",&a);

while(a>0){

inser(a);

printf("请输入学号:

");

scanf("%ld",&a);

}

}

voidinser(longb)

{

Node*last,*current,*p;

current=head;

while(current!

=NULL&&b>current->student.num){

last=current;

current=current->next;

}

if(current==NULL||bstudent.num){

printf("请输入姓名、分数:

");

p=(Node*)malloc(sizeof(Node));

p->student.num=b;

scanf("%s%f",p->student.name,&p->student.score);

p->next=NULL;

if(current==head){

p->next=head;

head=p;

}

else{

p->next=current;

last->next=p;

}

}

elseif(b==current->student.num)

printf("errorinputadifferentnumber:

");

}

voidprint()

{

Node*p=head;

printf("\n学号姓名成绩:

\n");

while(p!

=NULL){

printf("%ld%s%f\n",p->student.num,p->student.name,p->student.score);

p=p->next;

}

printf("\n");

}

voidfind(longb)

{

Node*p=head;

while(p!

=NULL&&b!

=p->student.num)

p=p->next;

if(!

p)printf("Nofound\n");

else{

printf("\n学号姓名成绩\n");

printf("%ld%s%f\n",p->student.num,p->student.name,p->student.score);

}

}

voidsearchname(char*s)

{

Node*p=head;

intflag=0;

printf("\n学号姓名成绩:

\n");

while(p!

=NULL)

{

if(strcmp(p->student.name,s)==0)

{

printf("%ld%s%f\n",p->student.num,p->student.name,p->student.score);

flag=1;

p=p->next;

continue;

}

elsep=p->next;

}

if(!

flag)printf("没有找到相关信息");

}

Node*del(longn)

{

Node*p=head,*last;

while(p->student.num!

=n){

last=p;

p=p->next;

}

if(p==NULL)returnp;

elseif(p==head)head=p->next;

elselast->next=p->next;

returnhead;

}

voidsort(intflag)

{

Node*p1,*p2,*k;

floatt1;

longt2;

chars[20];

for(p1=head;p1->next;p1=p1->next)

{

k=p1;

for(p2=p1->next;p2;p2=p2->next)

if(flag==1&&k->student.scorestudent.score||!

flag&&k->student.num>p2->student.num)

k=p2;

if(k!

=p1){

t1=p1->student.score;

p1->student.score=k->student.score;

k->student.score=t1;

t2=p1->student.num;

p1->student.num=k->student.num;

k->student.num=t2;

strcpy(s,p1->student.name);

strcpy(p1->student.name,k->student.name);

strcpy(k->student.name,s);

}

}

}

 

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 解决方案 > 学习计划

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2