已阅读5页,还剩24页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
河南工业大学 计科 0906 马飞扬 根据本报告 可完全实现建立运行宿舍管理系统 这是我 c 的课程设计 1 工程结构 初始信息 2 源代码 main cpp include 预编译语句 include include include using namespace std include show h 文件包含语句 include show2 h include denglu h include jianlixinxi h include chaxun h include xiugai h include shanchu h include huizong h include xiumima h include zhuce h include weisheng h void main int choice 0 记录选择 denglu 输入登录信息 show 显示菜单 cin choice while choice 0 循环输入选择 switch choice case 1 jianli break 建立宿舍信息 case 2 chaxun break 查询学生信息 case 3 huizong break 宿舍信息汇总 case 4 xiugai break 修改学生信息 case 5 zhuce break 添加学生信息 case 6 shanchu break 删除学生信息 case 7 weisheng break 宿舍卫生评比 case 8 xiumima break 修改登录信息 case 0 break default cout 您按错了 choice chaxun h void chaxue int renshu 按学号查询 void chaban int renshu 按班级查询 void chasu int renshu 按宿舍查询 struct student2 定义存储信息的结点结构 char name 20 char number 20 char banji 20 int sushehao student2 array1 100 定义存储信息的线性结构数组 void chaxun student2 p 辅助结点变量 int choice 0 int renshu 0 ifstream fin2 学生信息 txt if fin2 cout error p name p number p banji p sushehao renshu renshu fin2 close cout 1 按学号查询 cout t t t 2 按班级查询 n cout 3 按宿舍查询 n cout choice while choice 0 循环操作 switch choice case 1 chaxue renshu break case 2 chaban renshu break case 3 chasu renshu break case 0 break default cout 您输错了 endl break cout choice cout 已退出 endl show2 显示主菜单 void chaxue int renshu student2 p int i 0 char xuehao 20 cout xuehao 输入查询的学号 ifstream fin1 学生信息 txt if fin1 cout error endl exit 0 for int j 0 j p name p number p banji p sushehao if strcmp p number xuehao 找到相关信息后进行输出 cout 姓名 p name t t 学号 p number endl cout 班级 p banji t t 宿舍号 p sushehao endl i break fin1 close if i 0 cout 没有该生信息 endl void chaban int renshu 实现细节类似上个函数 student2 p int i 0 char banji 20 cout banji ifstream fin1 学生信息 txt if fin1 cout error endl exit 0 for int j 0 j p name p number p banji p sushehao if strcmp p banji banji cout 姓名 p name t t 学号 p number endl cout 班级 p banji t t 宿舍号 p sushehao endl i fin1 close if i 0 cout 没有该班学生信息 endl void chasu int renshu 实现细节类似上个函数 student2 p int i 0 int sushehao cout sushehao ifstream fin1 学生信息 txt if fin1 cout error endl exit 0 for int j 0 j p name p number p banji p sushehao if p sushehao sushehao cout 姓名 p name t t 学号 p number endl cout 班级 p banji t t 宿舍号 p sushehao endl i fin1 close if i 0 cout 该宿舍无人入住 endl denglu h void denglu char yonghu1 20 存储用户输入的登录信息 char mima1 10 char yonghu2 20 存储当前系统设定的登录信息 char mima2 10 cout yonghu1 cout mima1 ifstream fin1 登录信息 txt if fin1 cout error yonghu2 mima2 fin1 close if strcmp yonghu1 yonghu2 strcmp mima1 mima2 判断是否为合法用户 cout 用户名或密码错误 endl exit 0 huizong h void huizong char louhao 20 int loucheng 0 int fangjian 0 int rongliang 0 int i 0 记录宿舍楼的基本 信息 student2 array4 100 存储宿舍楼的所有学生信息 int susheshu 0 int renshu 0 记录宿舍楼已入住的宿舍数及总入住人数 ifstream fin 学生信息 txt if fin cout error array4 renshu name array4 renshu number array4 renshu banji array4 renshu sushehao renshu renshu 记录入住人数 fin close if renshu 0 susheshu for i 1 i renshu i 计算已入住的宿舍个数 if array4 i sushehao array4 i 1 sushehao susheshu ifstream fin1 宿舍信息 txt if fin1 cout error louhao 宿舍楼编号 fin1 loucheng 楼层个数 fin1 fangjian 每层房间数 fin1 rongliang 房间容量 fin1 close cout louhao 宿舍楼信息汇总 endl cout 已入住 renshu 名学生 输出已入住的人数 cout t t 剩余容纳量 loucheng fangjian rongliang renshu endl 剩余容纳量 cout 空房间数 loucheng fangjian susheshu endl 空房间数 show2 显示主菜单 jianlixinxi h struct student 存储学生信息的单链表结点存储结构 char name 20 char number 20 char banji 20 int sushehao student next struct sushe 存储各房间信息的单链表头结点 int renshu student next void jianli int choice cout choice if choice ofstream fout3 fout3 open 学生信息 txt if fout3 cout error endl exit 0 fout3 eof 格式化当前记录的学生信息 fout3 close char louhao 20 int loucheng int fangjian int rongliang 存储宿舍楼基本信息 cout louhao cout loucheng cout fangjian cout rongliang ofstream fout1 宿舍信息 txt if fout1 cout error endl exit 0 fout1 louhao endl 输入到文件 fout1 loucheng endl fout1 fangjian endl fout1 rongliang endl fout1 close for int i 0 i loucheng i 按楼层数逐个建立每层信息 sushe lou new sushe fangjian 定义存储每层信息的线性结构 for int j 0 j fangjian j 对该线性结构进行初始化 lou j renshu 0 lou j next NULL student p NULL 辅助结点变量 p new student cout 第 i 1 层信息 宿舍号 1 进入下一层 endl cout 宿舍号 i 1 100 i 1 100 fangjian 1 p sushehao 输入宿舍号以进行下面的操作 while p sushehao 1 sushe q NULL cout p name cout p number cout p banji if lou p sushehao 100 renshusushehao 100 renshu 0 空房间直接插入 lou p sushehao 100 next p p next NULL lou p sushehao 100 renshu else 非空房间先找到链表尾结点再进行插入 q lou p sushehao 100 next for int m 0 msushehao 100 renshu 1 m q q next q next p p next NULL lou p sushehao 100 renshu else 房间已满输入无效 cout 该宿舍已满 此次输入无效 endl p new student cout p sushehao if p sushehao 1 退出本层信息输入后输入本层信息至文件 ofstream fout2 fout2 open 学生信息 txt ios app if fout2 cout error endl exit 0 for j 0 j fangjian j if lou j renshu 0 p lou j next for int s 0 s lou j renshu s fout2 name endl fout2 number endl fout2 banji endl fout2 sushehao next fout2 close delete lou cout 已建立宿舍信息 endl show2 显示主菜单 shanchu h void mingshan 按名字进行删除 void xueshan 按学号进行删除 void shanchu int choice 0 cout 1 按名字删除 cout t t 2 按学号删除 n cout choice while choice 0 循环操作 switch choice case 1 mingshan break case 2 xueshan break case 0 break default cout 您按错了 endl break cout choice cout 已退出 endl show2 显示主菜单 void mingshan student2 array3 100 存储当前所有学生信息 int renshu 0 char name 20 存储待删除信息的名字 int j 0 ifstream fin 学生信息 txt if fin cout error array3 renshu name array3 renshu number array3 renshu banji array3 renshu sushehao renshu renshu 记录人数 fin close cout name 输入待删除名字 for int i 0 i renshu i 循环查找线性表 if strcmp array3 i name name 找到相关信息 ofstream fout3 fout3 open 学生信息 txt if fout3 cout error endl exit 0 fout3 eof 格式化当前信息 fout3 close j ofstream fout fout open 学生信息 txt ios app if fout cout error endl exit 0 for int s 0 s renshu s 输入非删除信息至文件 if s i fout array3 s name endl fout array3 s number endl fout array3 s banji endl fout array3 s sushehao endl fout close cout 已删除 endl break if j 0 查找失败时 cout 不存在该生信息 endl void xueshan 实现细节于上个函数 student2 array4 100 int renshu 0 char number 20 int j 0 ifstream fin 学生信息 txt if fin cout error array4 renshu name array4 renshu number array4 renshu banji array4 renshu sushehao renshu renshu fin close cout number for int i 0 i renshu i if strcmp array4 i number number ofstream fout3 fout3 open 学生信息 txt if fout3 cout error endl exit 0 fout3 eof fout3 close j ofstream fout fout open 学生信息 txt ios app if fout cout error endl exit 0 for int s 0 s renshu s if s i fout array4 s name endl fout array4 s number endl fout array4 s banji endl fout array4 s sushehao endl fout close cout 已删除 endl break if j 0 cout 不存在该生信息 endl show h void show 主界面显示信息 time t t time cout 宿舍管理查询系统 endl cout t t t 时间 ctime cout n cout 1 建立宿舍信息 cout t t t t t t t 2 查询学生信息 n cout 3 宿舍信息汇总 cout t t t t t t t 4 修改学生信息 n cout 5 注册学生信息 cout t t t t t t t 6 删除学生信息 n cout 7 宿舍卫生评比 cout t t t t t t t 8 修改登录信息 n cout n cout 请选择 0 退出 show2 h void show2 进行操作后显示的主界面信息 cout n cout 1 建立宿舍信息 cout t t t t t t t 2 查询学生信息 n cout 3 宿舍信息汇总 cout t t t t t t t 4 修改学生信息 n cout 5 注册学生信息 cout t t t t t t t 6 删除学生信息 n cout 7 宿舍卫生评比 cout t t t t t t t 8 修改登录信息 n cout n cout 请选择 0 退出 weisheng h struct wei 宿舍卫生存储结构 int sushehao int score void sort wei l int low int high 快速排序函数 int partion wei l int low int high 返回枢轴位置 void weisheng student2 array5 100 学生信息存储结构 wei sheng 100 宿舍卫生信息存储结构 int renshu 0 int susheshu 0 int i 0 ifstream fin1 学生信息 txt if fin1 cout error array5 renshu name array5 renshu number array5 renshu banji array5 renshu sushehao renshu renshu 记录人数 fin1 close if renshu 0 sheng susheshu sushehao array5 i sushehao susheshu for i 1 i renshu i 建立已入住的宿舍信息存储数组 if array5 i 1 sushehao array5 i sushehao sheng susheshu sushehao array5 i sushehao susheshu cout 为各宿舍打分 0 100 endl 为各入住宿舍打分 for i 0 i susheshu i cout 宿舍 sheng i sushehao sheng i score wei l l sheng i susheshu 1 sort l 0 i 按得分对宿舍信息进行排序 ofstream fout3 fout3 open 宿舍卫生信息 txt if fout3 cout error endl exit 0 fout3 eof 格式化上次得分信息 fout3 close ofstream fout2 fout2 open 宿舍卫生信息 txt ios app if fout2 cout error endl exit 0 for i 0 i susheshu i 写入宿舍卫生信息至文件 fout2 sheng i sushehao endl fout2 sheng i score endl fout2 close int susheshu2 susheshu cout 得分最高的宿舍为 2 cout sheng susheshu2 2 sushehao susheshu2 cout endl i 0 if sheng i score 60 cout 不及格宿舍有 sheng i sushehao i while i susheshu cout sheng i sushehao i cout endl else cout 所有宿舍均及格 endl else cout 当前宿舍信息为空 endl cout 各宿舍得分已输入文件 endl show2 显示主菜单 void sort wei l int low int high 快速排序函数 if low high int key partion l low high sort l low key 1 sort l key 1 high int partion wei l int low int high 返回枢轴位置 int p 0 int q 0 int key l low score while low high while low key high p l low score q l low sushehao l low score l high score l low sushehao l high sushehao l high score p l high sushehao q while low high p l low score q l low sushehao l low score l high score l low sushehao l high sushehao l high score p l high sushehao q return low xiugai h void mingxiu int renshu 按名字修改 void xuexiu int renshu 按学号修改 student2 array2 100 存储学生信息 void xiugai int choice 0 int renshu 0 ifstream fin 学生信息 txt if fin cout error array2 renshu name array2 renshu number array2 renshu banji array2 renshu sushehao renshu renshu fin close cout 1 按名字修改 cout t t 2 按学号修改 n cout choice while choice 0 switch choice case 1 mingxiu renshu break case 2 xuexiu renshu break case 0 break default cout 您按错了 endl break cout choice cout 已退出 endl show2 void mingxiu int renshu char na 20 int j 0 cout na for int i 0 i renshu i if strcmp array2 i name na 找到相关信息进行修改 cout array2 i name cout array2 i number cout array2 i banji cout array2 i sushehao j ofstream fout3 fout3 open 学生信息 txt if fout3 cout error endl exit 0 fout3 eof fout3 close ofstream fout fout open 学生信息 txt ios app if fout cout error endl exit 0 for int s 0 s renshu s 写入修改后的信息至文件 fout array2 s name endl fout array2 s number endl fout array2 s banji endl fout array2 s sushehao endl fout close cout 已修改 break if j 0 查找失败 cout 不存在该生信息 endl void xuexiu int renshu 实现细节类是与上个函数 char number 20 int j 0 cout number for int i 0 i renshu i if strcmp array2 i number number cout array2 i name cout array2 i number cout array2 i banji cout array2 i sushehao j ofstream fout3 fout3 open 学生信息 txt if fout3 cout error endl exit 0 fout3 eof fout3 close ofstream fout fout open 学生信息 txt ios app if fout cout error endl exit 0 for int s 0 s renshu s fout array2 s name endl fout array2 s number endl fout array2 s banji endl fout array2 s sushehao endl fout close cout 已修改 break if j 0 cout 不存在该生信息 endl xiumima h void xiumima char yonghu1 20 存储登录信息的辅助数组 char mima1 10 char yonghu 20 char mima 10 ifstream fin1 登录信息 txt if fin1 cout error yonghu 读入旧的登录信息 mima fin1 close cout yonghu1 cout mima1 if strcmp yonghu1 yonghu strcmp mima1 mima 判断是否为合法用户 cout yonghu cout mima cout 已完成修改 endl ofstream fout 登录信息 txt if fout cout error endl exit 0 fout yonghu endl 修改登录信息 fout mima endl else cout 输入错误 自动返回 endl show2 zhuce h struct student3 存储学生信息及其对应宿舍的层数 char name 20 char number 20 char banji 20 int sushehao int cheng2 void zhuce student pp NULL pp new student 辅助存储变量 char louhao 20 int loucheng int fangjian int rongliang int renshu1 0 int cheng2 0 student3 lou3 100 存储所有学生信息 ifstream fin1 宿舍信息 txt if fin1 cout error louhao loucheng fangjian rongliang fin1 close cout 宿舍号 100 提示信息 cout fangjian 1 100 cout 100 loucheng cout 100 loucheng fangjian 1 pp sushehao if pp sushehao 0 exit 0 cheng2 pp sushehao 100 ifstream fin2 学生信息 txt if fin2 cout error lou3 renshu1 name lou3 renshu1 number lou3 renshu1 banji lou3 renshu1 s ushehao renshu1 renshu1 fin2 close for int i 0 i renshu1 i 判断每个学生对应的宿舍所在层数 lou3 i cheng2 lou3 i sushehao 100 ofstream fout1 学生信息 txt if fout1 cout error endl exit 0 fout1
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 电化学精制装置操作工岗前操作能力考核试卷含答案
- 积材工操作技能模拟考核试卷含答案
- 园林康养师岗位理论综合实践考核试卷含答案
- 石英玻璃制品加工工安全生产能力考核试卷含答案
- 高中语文文言虚词用法练习题含答案
- 2026年5s管理培训考试试题及答案
- 加油站地下水位监测管理规范
- 2026年7月化验室安全考试题及答案
- 2026年爆破人员考试试题及答案
- 2026年秋季初三学业提速状态回归专项教育课件
- 2025-2026学年北京市海淀区统编版六年级上册期末考试语文试卷
- 2026年合肥市中煤矿山建设集团安徽绿建科技有限公司招聘笔试参考题库附带答案详解
- 2025-2026学年物态变化大单元教学设计
- 数据的“分身术”与“接力赛”-七年级信息技术网络传输原理初探
- 早孕关爱门诊咨询要点专家共识(2025年版)
- 2026重庆医疗器械质量检验中心招聘2人笔试参考题库及答案解析
- 2026届高考一轮精准复习:《答司马谏议书》复习课件
- 电气操作监护制度规范
- 《中国贫血防治指南》
- 2025年及未来5年市场数据中国半导体封装用劈刀行业竞争格局分析及投资战略咨询报告
- 饮料厂出售合同范本
评论
0/150
提交评论