学生宿舍管理系统.docx
《学生宿舍管理系统.docx》由会员分享,可在线阅读,更多相关《学生宿舍管理系统.docx(21页珍藏版)》请在冰豆网上搜索。
![学生宿舍管理系统.docx](https://file1.bdocx.com/fileroot1/2022-11/25/684408a1-2b0c-4d06-b030-cb2ecfc9ebc2/684408a1-2b0c-4d06-b030-cb2ecfc9ebc21.gif)
学生宿舍管理系统
目录
前言C语言程序综合设计任务书----------------------------------------------------2
§1.0任务书--------------------------------------------------------------------------------------------------3
§2.7小型学生成绩管理系统-------------------------------------------------------------------------4
§2.1总体设计-------------------------------------------------------------------------------------------------4§2.2模块划分-------------------------------------------------------------------------------------------------4
§2.3算法说明--------------------------------------------------------------------------------------------------4
§2.4各函数模块功能及流程图----------------------------------------------------------------------------4
§2.5程序测试-------------------------------------------------------------------------------------------------7
§2.6结论--------------------------------------------------------------------------------------------------------7
§2.7原程序清单----------------------------------------------------------------------------------------------7
§3.0体会及建议-----------------------------------------------------------------------------------------15
§4.0参考文献--------------------------------------------------------------------------------------------15
C语言程序综合设计任务书
(设计性实验)
一.实验目的
1、进一步掌握计算机程序设计基础基本概念,理解其原理与方法。
2、进一步理解和巩固所学的理论知识,掌握高级语言程序设计的编程技巧。
3、培养分析解决实际问题的能力,培养进行高级语言程序设计的实际编程能力。
二.实验任务
1.用C语言设计一个综合应用程序。
主要设计内容有数据库管理程序设计、图形设计、科学计算程序设计、简单游戏程序设计等。
2.学生可以结合自己的专业及兴趣爱好自由命题,也可以从已给几类题目中任选一题,下面题目只是基本要求,鼓励同学自主创新、自由发挥。
三.实验要求
1.要求学生自主完成以下工作:
1)查阅资料,选定题目。
2)制定方案,进行程序总体设计和详细设计。
3)程序详细设计,调试,运行。
4)撰写设计报告。
2.实验报告内容包括:
封面、实验目的、实验内容、设计方案制定、总体设计、详细设计、源程序清单(要求有详细注释)、总结与体会。
一、任务书
§2.7学生宿舍管理系统设计
功能:
实现简单的学生宿舍基本信息管理,宿舍的基本信息包括楼号、房间号、面积、所容纳人数、已入住人数等
基本要求:
1.设计简单的菜单,能够进行系统功能选择。
2.实现信息的录入功能。
3.在已有信息的基础上添加新的记录。
4.删除指定房间号的记录。
5.修改指定房间号的记录
6.实现信息的浏览功能
7.按房间号查询功能
8.按已入住人数排序功能
相关知识:
结构体、数组、常用算法(排序、查找、删除)
扩充功能:
1)在数据维护(录入、删除、修改、添加)功能时,要求输入用户名和密码,以防信息被非法修改。
提示:
在主菜单界面中,将录入、删除、修改、添加功能合并为数据库维护功能,当选择此选项时,要求用户输入用户名和密码,如设数据库维护人员为2人,则在程序中可相应设置2个用户名和密码,只有正确时,才进入下一级维护菜单。
(密码设置参阅字符串操作部分)
2)增加查询方式,如可以根据房间号查询,根据书名查询,及多种排序方式
提示:
在查询或排序中加入分支程序,不同的分支采用不同的查询方式,每种查询方式是一个独立的模块(函数)
3)将数据信息以文件的形式存盘,数据库信息的各种操作最后都能被存储,存储前有提示,并且能打开。
提示:
在主菜单中增加文件打开、存储选项,C语言的文件操作都是通过库函数实现的,参考关于文件的库函数使用即可。
4)采用动态链表的方式进行设计。
提示:
要求了解链表的建立、插入、删除原理,掌握C语言的动态内存分配函数的应用。
链表编程可参考苏小红编《C语言大学实用教程》P314~325第8.5节动态数据结构和P362~374的例子。
二、学生宿舍管理系统设计
1、总体设计
实现简单的学生宿舍基本信息管理
用动态链表、结构体等相关知识完成如下内容:
1)、简单菜单界面,按1-6键选择选项
2)、实现各个函数的功能
2、模块划分
主模块:
main()/*主函数*/
其它模块:
Student*load()/*从文件中读数据建立链表*/
save()/*将修改后的链表中的信息存进文件中*/
Add_student()/*添加学生信息*/
del_stu()/*按学号删除学生信息*/
find_student()/*按学号查找学生信息*/
ame_student()/*修改学生信息*/
print_student()/*输出学生信息*/
3、算法说明
Step1输出主菜单
Step2按1-6键选择
Step3实现各个函数的功能
4、各函数功能及流程图
main()/*主函数*/
Student*load()/*从文件中读数据建立链表*/
save()/*将修改后的链表中的信息存进文件中*/
Add_student()/*添加学生信息*/
del_stu()/*按学号删除学生信息*/
find_student()/*按学号查找学生信息*/
ame_student()/*修改学生信息*/
print_student()/*输出学生信息*/
流程图如下:
欢迎进入学生宿舍管理系统
打印1添加学生信息2删除学生信息3查找学生信息4修改学生信息5输出学生信息
6退出程序
请输入1----6,其他输入非法!
12
真
p=head,q=stud1,q1链表是空表
链表是空表假
将所指的结点作为唯一结点
当num!
=p->num以及p所指的结点不是表尾结点
输出空表
是否p=head
打印:
1:
修改房间号2:
修改楼号
3:
修改面积4:
修改所容纳人数
5:
修改已入住人数
请输入1-5其它非法!
真
输出无该学生信息
退出程序
无学生信息
打印输入修改的已入住人数,修改
打印输入修改的所容纳人数,修改
打印输入修改的面积,修改
打印输入修改的;楼号,
修改
4
p->stu_num
!
=stu_num
打印输入修改的房间号,
复制
2
3
5
1
6
p->stu_num=stu_num
输出无该学生信息
输出无该学生信息
输出学生信息
输出不存在学生信息
p->stu_num!
=stu_num
p->stu_num=stu_num
循环输出学生信息
链表是一个空表
假
假
假
真
真
链表是一个空表
5
head=q
q->next=p
(插到表头之前)
是
假
真
q
否
p=q
p=p->next
(p后移一个位置)
5、程序测试
(1)静态检查;
(2)静态检查无误后,上机调试;
(3)改正语法错误;运行。
检查错误方法:
(1)将程序与流程图仔细对照,如果流程图正确,程序写错了,错误很容易发现;
(2)采取“分断检查”的方法,不断缩小检查区,就可能发现错误所在。
6、结论:
此程序可以在TC中正常、正确运行。
实现学生宿舍成绩管理。
7、原程序清单
程序原代码
#include
#include
#include
#include
typedefstructstudent_info
{
charflour_num;
introom_num;
intarea;
intcontain_people;
intreside_people;
structstudent_info*next;
}Student;
Student*head;
Student*load()
{
FILE*fp;
Student*head_1,*p,*q;
head_1=NULL;
fp=fopen("student","rb");
if(fp==NULL)
{fp=fopen("student","wb");fclose(fp);returnhead_1;}
p=(Student*)malloc(sizeof(Student));
if(fread(p,sizeof(Student),1,fp)!
=1)returnhead_1;
head_1=p;
while(!
feof(fp))
{
q=p;
p=(Student*)malloc(sizeof(Student));
fread(p,sizeof(Student),1,fp);
q->next=p;
}
q->next=NULL;
free(p);
fclose(fp);
returnhead_1;
}
intsave()
{
FILE*fp;
fp=fopen("student","wb");
while(head!
=NULL)
{
fwrite(head,sizeof(Student),1,fp);
head=head->next;
}
fclose(fp);
return0;
}
intAdd_student()
{
Student*p,*q;
Student*stud1;
charflag='y';
stud1=(Student*)malloc(sizeof(Student));
while(flag=='y'||flag=='Y')
{
q=p=head;
printf("PleaseenterCanadatofillthestudentinformation:
\n");
printf("flour_numroom_numareacontain_peoplereside_people\n");
scanf("%d%d%d%d%d",&stud1->flour_num,&stud1->room_num,&stud1->area,&stud1->contain_people,&stud1->reside_people);
stud1->next=NULL;
fflush(stdin);
if(head==NULL)head=stud1;
else
{
while(p->room_numroom_num&&p->next!
=NULL)
{
q=p;p=p->next;
}
if(p->room_num>stud1->room_num)
if(p==head){stud1->next=head;head=stud1;}
else
{
q->next=stud1;stud1->next=p;
}
elsep->next=stud1;
}
stud1=(Student*)malloc(sizeof(Student));
printf("addend,whetherornottocontinuetoadd,'y'or'Y'tocontinue,otherwiseexit:
\n");
flag=getchar();
fflush(stdin);
}
free(stud1);
system("cls");
return0;
}
intdel_stu()
{
Student*p,*q;
introom_num;
charflag='y';
inttage=0;
while(flag=='y'||flag=='Y')
{
p=head;
q=NULL;
printf("\ninputthedeleteroomnumber!
\n");
scanf("%d",&room_num);
if(head==NULL)
{
printf("Thereisnostudentinformation\n");return0;
}
while(p!
=NULL)
{
if(p->room_num==room_num)
{
tage=1;
if(p==head)head=head->next;
elseq->next=p->next;
free(p);break;
}
q=p;p=p->next;
}
if(tage==0)printf("Todeletethestudentinformationdoesnotexist\n");
tage=0;
printf("Todeletetheend,whetherornottocontinuetheoperationtoremove:
yorYtocontinue,nottoend\n");
fflush(stdin);
scanf("%c",&flag);
}
system("cls");
return0;
}
intfind_student()
{Student*p;
charflag='y';
introom_num;
inttage=0;
while(flag=='y'||flag=='Y')
{printf("inputthefindingroomnumber!
\n");
scanf("%d",&room_num);
p=head;
if(head==NULL){printf("Thereisnostudentinformation!
\n");return0;}
else
while(p!
=NULL)
if(p->room_num==room_num)
{tage=1;
printf("Youhavetofindtheinformationstudentsareasfollows:
\n");
printf("%d\t%d\t%d\t%d\t%d\n",p->flour_num,p->room_num,p->area,p->contain_people,p->reside_people);
break;
}
elsep=p->next;
if(tage==0)printf("Noinformationonthestudents\n");
tage=0;
printf("Findtheend,whetherornottocontinuetheoperationtofind:
ytocontinueorY,whohasquit!
\n");
fflush(stdin);
scanf("%c",&flag);
}
return0;
}
intame_student()
{Student*p;
introom_num;
inttage=0;
intchiose;
charflag='y';
printf("inputthechangeroomnumber!
\n");
scanf("%d",&room_num);
p=head;
while(flag=='y'||flag=='Y')
{if(head==NULL){printf("Studentsthereisnoinformation!
\n");return0;}
while(p!
=NULL)
{if(p->room_num==room_num)
{tage=1;
printf("Requestedtoamendtheelectoralcode!
\n");
printf("1:
\n");
printf("2:
\n");
printf("3:
printf("4:
\n");
printf("5:
\n");
printf("pleaseenter1----5!
elseillegal!
\n");
scanf("%d",&chiose);
switch(chiose)
{case1:
{charflour_num;
printf("Pleaseentertheflournumberchanges!
\n");
scanf("%d",&flour_num);
p->flour_num=flour_num;
break;
}
case2:
{introom_num;
printf("Pleaseentertheroomnumberchanges!
\n");
scanf("%d",&room_num);
p->room_num=room_num;
break;
}
case3:
{intarea;
printf("Pleaseenterthearea!
\n");
scanf("%d",&area);
p->area=area;
break;
}
case4:
{intcontain_people;
printf("Pleaseenterthecontain_people!
\n");
scanf("%d",&contain_people);
p->contain_people=contain_people;
break;
}
case5:
{intreside_people;
printf("Pleaseenterthereside_people!
\n");
scanf("%d",&reside_people);
p->reside_people=reside_people;
break;
}
default:
{printf("Thereisnosuchoperation!
\n");break;}
}break;
}
elsep=p->next;
}
if(tage==0)printf("Noinformationonthestudents!
\n");
tage=0;
printf("Theendoftherevision,whethertomodifytheoperationofstudentinformation:
ytocontinueorY,whohasquit!
\n");
fflush(stdin);
scanf("%c",&flag);
}
fflush(stdin);
system("cls");
return0;
}
intprint_student()
{Student*p;
p=head;
if(head==NULL){printf("Noinformationonthestudents!
\n");return0;}
printf("flournumber\tRoomnumber\tarea\tcontainpeople\tresidepeple\n");
printf("============================================\n");
while(p!
=NULL)
{printf("%d\t%d\t%d\t%d\t%d\n",p->flour_num,p->room_num,p->area,p->contain_people,p->reside_people);
p=p->next;
}
printf("============================================\n");
printf("Theendoftheoutput!
\n");
return0;
}
intmain()
{inttage;
head=load();
while
(1)
{
printf(">>>>>>>>>>>>>>>>>WelcometotheStudentManagementSystem!
<<<<<<<<<<<<<<<<<<<<>\n");
printf("1:
<<\n");
printf("2:
<<\n");
printf("3:
<<\n");
printf("4:
<<\n");
printf("5:
<<