当前位置:文档之家› 数据结构课程设计学生信息管理系统

数据结构课程设计学生信息管理系统

题目2。

学生信息管理系统一、课程设计目的1.数据结构课程设计是综合运用数据结构课程中学到的几种典型数据结构,以及程序设计语言(C语言),自行实现一个较为完整的应用系统的设计与开发2.通过课程设计,自己通过系统分析、系统设计、编程调试,写实验报告等环节,进一步掌握应用系统设计的方法和步骤,灵活运用并深刻理解典型数据结构在软件开发中的应用。

3.学会将知识应用于实际的方法,提高分析和解决问题的能力,增加综合能力。

学生信息管理系统:(1)熟练掌握链表存储结构及其建立过程和常用操作;(3)学会自己调试程序的方法并掌握一定的技巧二、课程设计内容建立学生信息管理系统,通过链表实现对学生信息的输入,查找,删除,插入和排序等操作。

三、需求分析1.每位学生的信息有:学号,姓名,性别,出生日期,E—mile,电话,c成绩,数学成绩等,用链表对学生的信息进行存储。

2.全部数据可以只放在内存中;3.系统能实现的操作和功能如下:a)输入学生信息:对不同学生分别输出下列信息:学号,姓名,性别,出生日期,E—mile,电话,c成绩,数学成绩等。

b) 查找学生信息:根据学生的学号或姓名对学生的信息进行查找。

c)删除学生信息:删除某个学生的所有信息。

d) 插入学生信息:将某个学生的信息插入到已经输入的信息中.e)显示学生信息:将所有学生的信息显示出来.f)排序:将所有学生按某个学科的成绩依次排序。

四、概要设计1.系统结构图(功能模块图)2.功能模块说明①.输入学生信息,creat()函数:建立单向链表,组织循环,将学生的信息依次录入.②:查找学生信息:a.按学号查找,find1()函数;b。

按姓名查找,find2()函数;③.删除学生信息,del()函数:建立指针,在链表中寻找要删除信息的学生的学号,找到后p—〉next=p—〉next-〉next,将其删除。

④.插入学生信息,insert()函数;输入要插入的信息,建立指针,寻找要插入的节点。

⑤.显示学生信息,print()函数;将以存在的学生信息输出⑥.按某科成绩对学生进行排序,sort()函数;五、详细设计及运行结果1。

菜单:2。

creat()函数。

Compare()Add添加且输入np!=null输入信息p=p->nextp==null存入链表显示最终结果fclose(fp)结束3. find ()函数.查找成功,输出输入学生信息p :null否find()p->num:num !==没有该学生信息=结束find1():find2():3。

del()函数。

没有该学生信息输入学号del()p:null =结束p:null 否p->num:num!=否p0->next=p->next 删除成功4。

insert()函数。

5. print()函数.没有该学生信息输入信息insert()p->num:a !=结束head:null 否p->p->next!=否s->next=hesd,hesd=s插入成功q->next=s;s->next=p插入成功=是6. sort()函数。

排序完毕,输出信息sort ()结束head:null 否没有学生信息可以查询是p->next:t->nextt->next=p分数大的放在前面,p 始终指向第一个节点p :null !==六、调试情况,设计技巧及体会通过这次课程设计,我对这门课又有了一个新的理解,最大的喜悦不是写出程序,而是从中学会了怎么去写,该如何去写,在老师的严格监督下,自己也养成了独立思考的习惯,真的从中得到了很多好处,从思想到着手,所有都是程序化的,必须踏踏实实的来.通过学生信息管理系统的设计,使我对链表有了更深的了解,也懂得了如何用链表进行输入,插入,排序等操作,两个礼拜的实习很快就过去了,这一次真的学到了很多东西,我也将会将自己所学到的东西用到自己以后的学习中去。

七、参考文献C语言程序设计—-——-——-——--——科学出版社数据结构(C语言描述)---—-清华大学出版社数据结构(使用C语言)——-——电子科技大学出版社八、附录:源代码#include〈stdio。

h〉#include〈string。

h〉#include<stdlib.h〉#define N sizeof(struct stu)void clearscreen() /*清屏函数*/{getchar();system(”cls”);}struct date /*定义出生年月日的结构体*/{int year;int mouth;int day;};struct stu /*定义学生信息的结构体*/{ int number;char name[30];char sex[5];struct date birthday;char mail[30];char phone[30];int cscore,mscore;struct stu *next;};/*输出函数*/int print(struct stu *p){while(p!=NULL) /*如果P所指的结点不为空执行循环*/{ printf(”学号姓名性别出生日期E—mail 电话C成绩数学成绩\n”);printf(” %2d%6s%6s%8d—%2d—%2d%11s%11s%6d%8d\n",p-〉number,p—>name,p-〉sex,p—>birthday。

year,p—>birthday.mouth,p-〉birthday.day,p—〉mail,p-〉phone,p—〉cscore,p—>mscore);p=p-〉next;}printf(”\n\n按回车键返回\n\n”);getchar();return 0;}/*创建链表*/struct stu *creat(){ struct stu *p,*head;int i,k;printf(”请输入学生的数:\n”);scanf("%d",&k);p=head=(struct stu *)malloc(N);printf("请输入学号\n”);scanf(”%d",&p—〉number);printf(”姓名\n”);scanf(”%s”,&p—〉name);printf(”性别\n");scanf(”%s”,&p-〉sex);printf(”出生日期\n");scanf("%d-%d—%d”,&p—>birthday。

year,&p—>birthday。

mouth,&p—>birthday.day);printf(”E—mail\n”);scanf("%s”,&p—〉mail);printf(”电话\n”);scanf(”%s”,&p—>phone);printf(”c成绩\n”);scanf("%d”,&p—>cscore);printf(”数学成绩\n");scanf(”%d”,&p->mscore);if(k〉1)for(i=1;i<k;i++){ p—>next=(struct stu *)malloc(N);p=p-〉next;printf(”请输入学号\n”);scanf(”%d",&p—〉number);printf(”姓名\n”);scanf("%s",&p-〉name);printf(”性别\n”);scanf(”%s”,&p->sex);printf("出生日期\n”);scanf("%d—%d—%d”,&p—〉birthday.year,&p—〉birthday.mouth,&p—>birthday。

day);printf("E-mail\n”);scanf("%s",&p—〉mail);printf("电话\n");scanf(”%s”,&p->phone);printf(”c成绩\n”);scanf("%d",&p—〉cscore);printf(”数学成绩\n”);scan f(”%d”,&p—>mscore);}p-〉next=NULL;return head;}/*查找链表*/struct stu *find1(struct stu *p){ int number;if(p==NULL){printf("\n提示:没有资料可以查询!\n");return 0;}printf(”请输入要查找的学生学号:”);scanf(”%d”,&number);while(p!=NULL){if(p—>number==number){return(p);break;}elsep=p->next;}return NULL;}struct stu *find2(struct stu *p){char name[30];if(p==NULL){printf("\n提示:没有资料可以查询!\n”);return 0;}printf(”请输入要查找的学生姓名:”);scanf(”%s",name);while(p!=NULL){if(strcmp(p-〉name,name)==0)return(p);elsep=p—〉next;}return NULL;}/*删除链表*/int del(struct stu **h){int number;struct stu *p,*p0;if(*h==NULL)return 0;printf("请输入要删除的学号\n”);scanf("%d",&number);p0=*h;if(p0—〉number==number){*h=p0—〉next;free(p0);return 1;}p=p0—>next;while(p!=NULL){if(p-〉number==number){p0—〉next=p—>next;free(p);return 1;}p0=p;p=p—〉next;}printf(”\n按回车键返回\n”);getchar();return 0;}/*插入链表*/int insert (struct stu **h){struct stu *p,*p0;p=(struct stu *)malloc(N);printf(”请输入要插入的学号\n”);scanf("%ld”,&p—〉number);p0=*h;if(p0—>number==p—>number)return 0;printf("姓名\n");scanf("%s”,&p->name);printf("性别\n”);scanf(”%s”,&p—〉sex);printf(”出生日期\n”);scanf(”%d%d%d”,&p—〉birthday.year,&p->birthday.mouth,&p-〉birthday.day);printf(”E—mail\n");scanf(”%s”,&p->mail);printf(”电话\n”);scanf("%s",&p-〉phone);printf(”c成绩\n”);scanf(”%d”,&p—>cscore);printf("数学成绩\n");scanf(”%d”,&p—〉mscore);p—〉next=NULL;if(*h==NULL){*h=p;return 1;}p0=*h;if(p0—>number〉p-〉number){p—>next=*h;*h=p;return 1;}while(p0-〉next!=NULL&&p0->next—>number〈p—〉number)p0=p0->next;if(p0—>next==NULL){p0—〉next=p;return 1;}p—〉next=p0—〉next;p0—〉next=p;printf(”\n\n按回车键返回\n\n");getchar();return 1;}/*排序*/struct stu* sort(struct stu *p0){struct stu *t,*p,*q,*z;if(p0==NULL){printf("没有学生信息可排序!\n”);return 0;}if((p0==NULL)||(p0—>next==NULL))/*当节点不存在或者只有一个节点时*/ {return p0;}t=p0;p=t-〉next;t—〉next=NULL;/*将头节点孤立出来*/while(p) /*t始终指向头节点*/{q=p-〉next;if(p->cscore〉t->cscore)/*用头节点的后一个节点与头节点进行比较*/{p—〉next=t;/*将分数大的放在前面*/t=p; /*t始终指向当前第一个节点*/}else{z=t;while(z—>next&&z-〉next->cscore>=p-〉cscore)z=z—〉next;p->next=z—〉next;z-〉next=p;}p=q;}p0=t;return p0;}void main()struct stu *head,*p;int a;int b;printf("*****************************西安邮电学院学生管理系统***************************\n”);printf(”要进入系统请按任意键\n");getchar();printf("*****************************欢迎您!您已进入管理系统***************************\n");printf("*********************************学生成绩管理系统*******************************\n”);do{clearscreen();printf(”学生纪录操作:\n”);printf(”1:输入学生信息\n");printf("2:查找学生信息\n");printf(”3:删除学生信息\n”);printf(”4:插入学生信息\n");printf(”5:显示学生信息\n");printf(”6:按C语言成绩排序\n”);printf(”0:退出系统\n");printf("请选择(0~6):”);scanf("%d",&b);switch(b){case 1:head=creat();print(head);break;case 2:printf(”请输入要查找的种类:如为学号请输1,如为姓名请输2:\n");scanf(”%d”,&a);switch(a){case 1:p=find1(head);break;case 2:p=find2(head);break;}if(p){printf(”找到情况如下:\n");getchar();printf(”学号:%d 姓名:%s 性别:%s 出生日期:%d—%d—%d E—mail:%s 电话:%s C成绩:%d 数学成绩:%d\n”,p—>number,p—>name,p->sex,p->birthday.year,p—〉birthday。

相关主题