c宿舍管理系统实现.doc

上传人:wj 文档编号:1215309 上传时间:2023-04-30 格式:DOC 页数:29 大小:257.50KB
下载 相关 举报
c宿舍管理系统实现.doc_第1页
第1页 / 共29页
c宿舍管理系统实现.doc_第2页
第2页 / 共29页
c宿舍管理系统实现.doc_第3页
第3页 / 共29页
c宿舍管理系统实现.doc_第4页
第4页 / 共29页
c宿舍管理系统实现.doc_第5页
第5页 / 共29页
c宿舍管理系统实现.doc_第6页
第6页 / 共29页
c宿舍管理系统实现.doc_第7页
第7页 / 共29页
c宿舍管理系统实现.doc_第8页
第8页 / 共29页
c宿舍管理系统实现.doc_第9页
第9页 / 共29页
c宿舍管理系统实现.doc_第10页
第10页 / 共29页
c宿舍管理系统实现.doc_第11页
第11页 / 共29页
c宿舍管理系统实现.doc_第12页
第12页 / 共29页
c宿舍管理系统实现.doc_第13页
第13页 / 共29页
c宿舍管理系统实现.doc_第14页
第14页 / 共29页
c宿舍管理系统实现.doc_第15页
第15页 / 共29页
c宿舍管理系统实现.doc_第16页
第16页 / 共29页
c宿舍管理系统实现.doc_第17页
第17页 / 共29页
c宿舍管理系统实现.doc_第18页
第18页 / 共29页
c宿舍管理系统实现.doc_第19页
第19页 / 共29页
c宿舍管理系统实现.doc_第20页
第20页 / 共29页
亲,该文档总共29页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

c宿舍管理系统实现.doc

《c宿舍管理系统实现.doc》由会员分享,可在线阅读,更多相关《c宿舍管理系统实现.doc(29页珍藏版)》请在冰点文库上搜索。

c宿舍管理系统实现.doc

河南工业大学计科0906马飞扬

根据本报告,可完全实现建立运行宿舍管理系统,这是我c++的课程设计。

1:

工程结构

初始信息:

2:

源代码

main.cpp:

#include//预编译语句

#include//

#include//

#include//

usingnamespacestd;//

#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"//

voidmain()

{

intchoice=0;//记录选择

denglu();//输入登录信息

show();//显示菜单

cin>>choice;

while(choice!

=0)//循环输入选择

{

switch(choice)

{

case1:

jianli();break;//建立宿舍信息

case2:

chaxun();break;//查询学生信息

case3:

huizong();break;//宿舍信息汇总

case4:

xiugai();break;//修改学生信息

case5:

zhuce();break;//添加学生信息

case6:

shanchu();break;//删除学生信息

case7:

weisheng();break;//宿舍卫生评比

case8:

xiumima();break;//修改登录信息

case0:

break;

default:

cout<<"您按错了!

"<

}

cin>>choice;

}

}

chaxun.h:

voidchaxue(intrenshu);//按学号查询

voidchaban(intrenshu);//按班级查询

voidchasu(intrenshu);//按宿舍查询

structstudent2//定义存储信息的结点结构

{

charname[20];

charnumber[20];

charbanji[20];

intsushehao;

};

student2array1[100];//定义存储信息的线性结构数组

voidchaxun()

{

student2p;//辅助结点变量

intchoice=0;

intrenshu=0;

ifstreamfin2("学生信息.txt");

if(!

fin2)

{

cout<<"error!

"<

exit(0);

}

while(!

fin2.eof())//从文件输入当前所有学生信息

{

fin2>>p.name>>p.number>>p.banji>>p.sushehao;

renshu++;

}

renshu--;

fin2.close();

cout<<"1:

按学号查询";

cout<<"\t\t\t2:

按班级查询\n";

cout<<"3:

按宿舍查询\n";

cout<<"请选择(0返回):

";

cin>>choice;

while(choice!

=0)//循环操作

{

switch(choice)

{

case1:

chaxue(renshu);break;

case2:

chaban(renshu);break;

case3:

chasu(renshu);break;

case0:

break;

default:

cout<<"您输错了!

"<

}

cout<<"请选择:

";

cin>>choice;

}

cout<<"已退出!

"<

show2();//显示主菜单

}

voidchaxue(intrenshu)

{

student2p;

inti=0;

charxuehao[20];

cout<<"查询的学号:

";//

cin>>xuehao;//输入查询的学号

ifstreamfin1("学生信息.txt");

if(!

fin1)

{

cout<<"error!

"<

exit(0);

}

for(intj=0;j

{

fin1>>p.name>>p.number>>p.banji>>p.sushehao;

if(!

strcmp(p.number,xuehao))//找到相关信息后进行输出

{

cout<<"姓名:

"<

"<

cout<<"班级:

"<

"<

i++;

break;

}

}

fin1.close();

if(i==0)

{

cout<<"没有该生信息!

"<

}

}

voidchaban(intrenshu)//实现细节类似上个函数

{

student2p;

inti=0;

charbanji[20];

cout<<"查询的班级:

";

cin>>banji;

ifstreamfin1("学生信息.txt");

if(!

fin1)

{

cout<<"error!

"<

exit(0);

}

for(intj=0;j

{

fin1>>p.name>>p.number>>p.banji>>p.sushehao;

if(!

strcmp(p.banji,banji))

{

cout<<"姓名:

"<

"<

cout<<"班级:

"<

"<

i++;

}

}

fin1.close();

if(i==0)

{

cout<<"没有该班学生信息!

"<

}

}

voidchasu(intrenshu)//实现细节类似上个函数

{

student2p;

inti=0;

intsushehao;

cout<<"查询的宿舍号:

";

cin>>sushehao;

ifstreamfin1("学生信息.txt");

if(!

fin1)

{

cout<<"error!

"<

exit(0);

}

for(intj=0;j

{

fin1>>p.name>>p.number>>p.banji>>p.sushehao;

if(p.sushehao==sushehao)

{

cout<<"姓名:

"<

"<

cout<<"班级:

"<

"<

i++;

}

}

fin1.close();

if(i==0)

{

cout<<"该宿舍无人入住!

"<

}

}

denglu.h:

voiddenglu()

{

charyonghu1[20];//存储用户输入的登录信息

charmima1[10];//

charyonghu2[20];//存储当前系统设定的登录信息

charmima2[10];//

cout<<"用户名(初始值:

111111):

";

cin>>yonghu1;

cout<<"密码(初始值:

000000):

";

cin>>mima1;

ifstreamfin1("登录信息.txt");

if(!

fin1)

{

cout<<"error!

"<

exit(0);

}

fin1>>yonghu2

>>mima2;

fin1.close();

if(strcmp(yonghu1,yonghu2)||strcmp(mima1,mima2))//判断是否为合法用户

{

cout<<"用户名或密码错误!

"<

exit(0);

}

}

huizong.h:

voidhuizong()

{

charlouhao[20];intloucheng=0;intfangjian=0;introngliang=0;inti=0;//记录宿舍楼的基本信息

student2array4[100];//存储宿舍楼的所有学生信息

intsusheshu=0;intrenshu=0;//记录宿舍楼已入住的宿舍数及总入住人数

ifstreamfin("学生信息.txt");

if(!

fin)

{

cout<<"error!

"<

exit(0);

}

while(!

fin.eof())//输入所有学生信息

{

fin>>array4[renshu].name>>array4[renshu].number>>array4[renshu].banji>>array4[renshu].sushehao;

renshu++;

}

renshu--;//记录入住人数

fin.close();

if(renshu!

=0)

{

susheshu++;//

for(i=1;i

{

if(array4[i].sushehao!

=array4[i-1].sushehao)

{

susheshu++;

}

}

}

ifstreamfin1("宿舍信息.txt");

if(!

fin1)

{

cout<<"error!

"<

exit(0);

}

fin1>>louhao;//宿舍楼编号

fin1>>loucheng;//楼层个数

fin1>>fangjian;//每层房间数

fin1>>rongliang;//房间容量

fin1.close();

cout<

"<

cout<<"已入住:

"<

cout<<"\t\t剩余容纳量:

"<

cout<<"空房间数:

"<

show2();//显示主菜单

}

jianlixinxi.h:

structstudent//存储学生信息的单链表结点存储结构

{

charname[20];

charnumber[20];

charbanji[20];

intsushehao;

student*next;

};

structsushe//存储各房间信息的单链表头结点

{

intrenshu;

student*next;

};

voidjianli()

{

intchoice;

cout<<"该操作将格式化之前记录,1确认,0返回:

";//防止失误操作

cin>>choice;//

if(choice)

{

ofstreamfout3;

fout3.open("学生信息.txt");

if(!

fout3)

{

cout<<"error"<

exit(0);

}

fout3.eof();//格式化当前记录的学生信息

fout3.close;

charlouhao[20];intloucheng;intfangjian;introngliang;//存储宿舍楼基本信息

cout<<"宿舍楼编号:

";//

cin>>louhao;//

cout<<"楼层数(小于11):

";//

cin>>loucheng;//

cout<<"每层房间数(小于101):

";//

cin>>fangjian;//

cout<<"房间容量(小于20):

";//

cin>>rongliang;//

ofstreamfout1("宿舍信息.txt");

if(!

fout1)

{

cout<<"error!

"<

exit(0);

}

fout1<

fout1<

fout1<

fout1<

fout1.close();

for(inti=0;i

{

sushe*lou=newsushe[fangjian];//定义存储每层信息的线性结构

for(intj=0;j

{

lou[j].renshu=0;//

lou[j].next=NULL;//

}

student*p=NULL;//辅助结点变量

p=newstudent;

cout<<"第"<

"<

cout<<"宿舍号("<<(i+1)*100<<"~"<<(i+1)*100+fangjian-1<<"):

";

cin>>p->sushehao;//输入宿舍号以进行下面的操作

while(p->sushehao!

=-1)

{

sushe*q=NULL;

cout<<"姓名:

";

cin>>p->name;

cout<<"学号:

";

cin>>p->number;

cout<<"班级:

";

cin>>p->banji;

if(lou[p->sushehao%100].renshu

{

student*q=NULL;

if(lou[p->sushehao%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(intm=0;msushehao%100].renshu-1;m++)

{

q=q->next;

}

q->next=p;

p->next=NULL;

lou[p->sushehao%100].renshu++;

}

}

else//房间已满输入无效

{

cout<<"该宿舍已满,此次输入无效!

"<

}

p=newstudent;

cout<<"宿舍号:

";

cin>>p->sushehao;

}

if(p->sushehao==-1)//退出本层信息输入后输入本层信息至文件

{

ofstreamfout2;

fout2.open("学生信息.txt",ios:

:

app);

if(!

fout2)

{

cout<<"error"<

exit(0);

}

for(j=0;j

{

if(lou[j].renshu!

=0)

{

p=lou[j].next;

for(ints=0;s

{

fout2<name<

fout2<number<

fout2<banji<

fout2<sushehao<

p=p->next;

}

}

}

fout2.close();

delete[]lou;

}

}

}

cout<<"已建立宿舍信息!

"<

show2();//显示主菜单

}

shanchu.h:

voidmingshan();//按名字进行删除

voidxueshan();//按学号进行删除

voidshanchu()

{

intchoice=0;

cout<<"1:

按名字删除:

";

cout<<"\t\t2:

按学号删除:

\n";

cout<<"请选择(0返回):

";

cin>>choice;

while(choice!

=0)//循环操作

{

switch(choice)

{

case1:

mingshan();break;

case2:

xueshan();break;

case0:

break;

default:

cout<<"您按错了!

"<

}

cout<<"请选择:

";

cin>>choice;

}

cout<<"已退出!

"<

show2();//显示主菜单

}

voidmingshan()

{

student2array3[100];//存储当前所有学生信息

intrenshu=0;

charname[20];//存储待删除信息的名字

intj=0;

ifstreamfin("学生信息.txt");

if(!

fin)

{

cout<<"error!

"<

exit(0);

}

while(!

fin.eof())//输入当前学生信息

{

fin>>array3[renshu].name>>array3[renshu].number>>array3[renshu].banji>>array3[renshu].sushehao;

renshu++;

}

renshu--;//记录人数

fin.close();

cout<<"待删除信息的名字:

";

cin>>name;//输入待删除名字

for(inti=0;i

{

if(!

strcmp(array3[i].name,name))//找到相关信息

{

ofstreamfout3;

fout3.open("学生信息.txt");

if(!

fout3)

{

cout<<"error"<

exit(0);

}

fout3.eof();//格式化当前信息

fout3.close;

j++;

ofstreamfout;

fout.open("学生信息.txt",ios:

:

app);

if(!

fout)

{

cout<<"error!

"<

exit(0);

}

for(ints=0;s

{

if(s!

=i)

{

fout<

fout<

fout<

fout<

}

}

fout.close();

cout<<"已删除!

"<

break;

}

}

if(j==0)//查找失败时

{

cout<<"不存在该生信息!

"<

}

}

voidxueshan()//实现细节于上个函数

{

student2array4[100];

intrenshu=0;

charnumber[20];

intj=0;

ifstreamfin("学生信息.txt");

if(!

fin)

{

cout<<"error!

"<

exit(0);

}

while(!

fin.eof())

{

fin>>array4[renshu].name>>array4[renshu].number>>array4[renshu].banji>>array4[renshu].sushehao;

renshu++;

}

renshu--;

fin.close();

cout<<"待删除信息的学号:

";

cin>>number;

for(inti=0;i

{

if(!

strcmp(array4[i].number,number))

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

当前位置:首页 > PPT模板 > 商务科技

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

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