宿舍管理系统源代码.docx
《宿舍管理系统源代码.docx》由会员分享,可在线阅读,更多相关《宿舍管理系统源代码.docx(16页珍藏版)》请在冰豆网上搜索。
宿舍管理系统源代码
#include
#include
#include
typedefstructStudent{
charname[20];
charsex[5];
intage;
charinstitute[20];
charspecialty[30];}Student;
typedefstructRoom{
introomnum;
introomarea;
inttotalnum;
intstunum;
Studentstu[10];
Room*next;}Room;
typedefstructStory{
charstorynum;
Room*room;
}Story;
/*
*/
Student*StudentCreat(intage,charname[],charinstitute[],charspecialty[],charsex[])
{
Student*Stu;
Stu=(Student*)malloc(sizeof(Student));
Stu->age=age;
strcpy(Stu->institute,institute);strcpy(Stu->name,name);strcpy(Stu->specialty,specialty);strcpy(Stu->sex,sex);
returnStu;
}
Room*RoomCreat(introom_num,introom_area,inttotal_num,intstu_num){
Room*R;
inti;
R=(Room*)malloc(sizeof(Room));
if(!
R)returnNULL;
R->roomnum=room_num;
R->roomarea=room_area;
R->totalnum=total_num;
R->stunum=stu_num;
R->next=NULL;
returnR;
}
Story*StoryCreat()
{
Story*S;
S=(Story*)malloc(sizeof(Story));
S->room=RoomCreat(0,0,0,0);
returnS;
}
Story*DormCreat()
{
Story*S,*control;
chari;
control=(Story*)malloc(26*sizeof(Story));if(!
control)returnNULL;
for(i='A';i<='Z';i++)
{
S=StoryCreat();S->storynum=i;control[i-'A']=*S;
}
returncontrol;
}
/*
*/
Story*StorySearch(Story*control,charstorynum)
{
returncontrol+(storynum-'A');
}
Room*RoomSearch(Room*R,introom_num)
{
while(R->next!
=NULL)
{if(R->next->roomnum==room_num)break;elseR=R->next;
}
returnR;
}
Student*StudentSearch(Room*R,charname[])
{
Student*p;
inti;
R=R->next;p=R->stu;
for(i=0;istunum;i++)
{if(strcmp(p->name,name)==0)returnp;elsep++;
}
returnNULL;
}
/*
*/
voidRoomInsert(Story*S,Room*R)
{
R->next=S->room->next;S->room->next=R;
}
voidStudentInsert(Room*R,Student*Stu)
{
R=R->next;
R->stu[R->stunum]=*Stu;
R->stunum++;
}
voidRoomDelete(Room*R)
{
Room*p;
R=R->next;
p=R;
R=R->next;
free(p);
}
voidStudentDelete(Room*R,Student*Stu)
{
R=R->next;
Student*p;for(p=R->stu;Stu
stunum-1;Stu++)*Stu=*(Stu+1);R->stunum--;
}
voidRoomRevamp(Room*R)
{
inti,k;
R=R->next;
printf("1、房号2、面积3、可容纳人数:
\n");
printf("要修改那一项:
\n");
scanf("%d",&i);switch(i)
{
case1:
{printf("房号:
");scanf("%d",&k);R->roomnum=k;break;
}
case2:
{printf("面积:
");scanf("%d",&k);R->roomarea=k;break;
}
case3:
{printf("可容纳人数:
");scanf("%d",&k);R->totalnum=k;break;
}
}
}
voidStudentRevamp(Student*Stu)
{
inti,k;
charstr[30];
printf("1、姓名2、性别3、学院4、专业5、年龄:
\n");
printf("要修改那一项:
\n");
scanf("%d",&i);switch(i)
{
case1:
{
printf("姓名:
");
scanf("%s",str);strcpy(Stu->name,str);break;
}
case2:
{
printf("性别:
");
scanf("%s",str);strcpy(Stu->sex,str);
break;
}
case3:
{
printf("学院:
");
scanf("%s",str);strcpy(Stu->institute,str);break;
}
case4:
{
printf("专业:
");
scanf("%s",str);strcpy(Stu->specialty,str);break;
}
case5:
{
printf("年龄:
");
scanf("%d",&k);
Stu->age=k;
break;
}
}
}
/*
*/
voidRoomScan(Room*R)
{
inti;
Student*p;
R=R->next;
printf("
房号:
%d\n",R->roomnum);
printf("
面积:
%d\n",R->roomarea);
printf("
可容纳人数:
%d\n",R->totalnum);
printf("
已住入人数:
%d\n",R->stunum);
printf("
成员:
");
for(i=0;istunum;i++)
{
p=&(R->stu[i]);
printf("%s",p->name);
}
putchar('\n');
}
voidStudentScan(Student*Stu)
{
printf("姓名:
%s\n",Stu->name);
printf("年龄:
%d\n",Stu->age);
printf("性别:
%s\n",Stu->sex);
printf("学院:
%s\n",Stu->institute);
printf("专业:
%s\n",Stu->specialty);
}
intmain()
{
introomnum,roomarea,totalnum,stunum,age;
intevent;
charname[20],institute[20],specialty[30],sex[5];
charstorynum,judge;
Story*control;
Story*S;
Room*R;
Student*Stu;
control=DormCreat();
do
、,I•、、+:
注意
{
printf("****************************
**********************************\n");
*\n");
*\n");
f*************************************************************
宿舍管理系统
\n\n\n");
printf("功能选择菜单:
\n");
printf("1、宿舍信息录入2、学生信息录入3、删除某个宿舍4、删除某个学生\n");
printf("5、宿舍信息浏览6、学生信息浏览7、宿舍信息修改8、学生信息修改\n");
scanf("%d",&event);
switch(event)
{
case1:
{
do
{
printf("请输入宿舍房间号,房间面积,可容纳人数,已住入人数:
(以空格隔开)\n");
fflush(stdin);
scanf("%c%d%d%d%d",&storynum,&roomnum,&roomarea,&totalnum,&stunum);S=StorySearch(control,storynum);
R=RoomCreat(roomnum,roomarea,totalnum,stunum);RoomInsert(S,R);
printf("宿舍信息录入成功!
\n");
fflush(stdin);
printf("是否继续录入宿舍信息(Y/N)\n");
scanf("%c",&judge);
}while(judge=='Y');break;
}
case2:
{
do
{
printf("请输入该生要入住的宿舍:
\n");fflush(stdin);
scanf("%c%d",&storynum,&roomnum);fflush(stdin);
S=StorySearch(control,storynum);R=S->room;
R=RoomSearch(R,roomnum);
printf("请输入该生姓名,性别,学院,专业,年龄:
(以空格隔开)\n");
scanf("%s%s%s%s",name,sex,institute,specialty);scanf("%d",&age);
Stu=StudentCreat(age,name,institute,specialty,sex);
StudentInsert(R,Stu);
printf("fflush(stdin);printf("scanf("%c",&judge);
}while(judge=='Y');
break;
学生信息录入成功!
\n");
是否继续录入学生信息(Y/N)\n");
break;
}
case3:
{
do
{
printf("请输入要删除的宿舍号码:
\n");fflush(stdin);
scanf("%c%d",&storynum,&roomnum);fflush(stdin);
S=StorySearch(control,storynum);R=S->room;
R=RoomSearch(R,roomnum);
RoomDelete(R);
printf("宿舍信息删除成功!
\n");
fflush(stdin);
printf("是否继续删除宿舍信息(Y/N)\n");
scanf("%c",&judge);
}while(judge=='Y');
break;
break;
}
case4:
{
do
{
printf("请输入要删除学生现住宿舍:
\n");fflush(stdin);
scanf("%c%d",&storynum,&roomnum);fflush(stdin);
S=StorySearch(control,storynum);
R=S->room;
R=RoomSearch(R,roomnum);
printf("请输入要删除学生的姓名:
\n");scanf("%s",name);
Stu=StudentSearch(R,name);
StudentDelete(R,Stu);
printf("学生信息删除成功!
\n");
fflush(stdin);
printf("是否继续删除学生信息(Y/N)\n");
scanf("%c",&judge);
}while(judge=='Y');
break;
break;
}
case5:
{
do
{
printf("请输入要浏览的宿舍号码:
\n");
fflush(stdin);
scanf("%c%d",&storynum,&roomnum);
fflush(stdin);
S=StorySearch(control,storynum);
R=S->room;
R=RoomSearch(R,roomnum);
RoomScan(R);
fflush(stdin);
printf("是否继续浏览宿舍(Y/N)\n");
scanf("%c",&judge);
}while(judge=='Y');
break;
break;
}
case6:
{
do
{
码:
\n");
printf("请输入要浏览学生的宿舍号
fflush(stdin);
scanf("%c%d",&storynum,&roomnum);
fflush(stdin);
S=StorySearch(control,storynum);
R=S->room;
R=RoomSearch(R,roomnum);
printf("请输入要浏览学生的姓名:
\n");
scanf("%s",name);
Stu=StudentSearch(R,name);
StudentScan(Stu);
fflush(stdin);
printf("是否继续浏览学生(Y/N)\n");
scanf("%c",&judge);
}while(judge=='Y');
break;
break;
}
case7:
{
do
{
printf("请输入要修改的宿舍号码:
\n");
fflush(stdin);
scanf("%c%d",&storynum,&roomnum);
fflush(stdin);
S=StorySearch(control,storynum);
R=S->room;
R=RoomSearch(R,roomnum);
RoomRevamp(R);
printf("宿舍信息修改成功!
\n");
fflush(stdin);
printf("是否继续修改(Y/N)\n");
scanf("%c",&judge);
}while(judge=='Y');
break;
break;
}
case8:
{
do
{
码:
\n");
printf("请输入要修改学生的宿舍号
fflush(stdin);scanf("%c%d",&storynum,&roomnum);
fflush(stdin);
S=StorySearch(control,storynum);
R=S->room;
R=RoomSearch(R,roomnum);
printf("请输入要修改学生的姓名:
\n");
scanf("%s",name);
Stu=StudentSearch(R,name);
StudentRevamp(Stu);
printf("学生信息修改成功!
\n");
fflush(stdin);
printf("是否继续修改(Y/N)\n");
scanf("%c",&judge);
}while(judge=='Y');
break;
break;
}
}
fflush(stdin);
printf("是否继续其他操作(Y/N)\n");
scanf("%c",&judge);
}while(judge=='Y');
system("pause");
}
欢迎您的下载,
资料仅供参考!
致力为企业和个人提供合同协议,策划案计划书,学习资料等等
打造全网一站式需求