资源描述:
《宿舍管理系统源代码》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、#include#include#includetypedefstructStudent{charname[20];charsex[5];intage;charinstitute[20];charspecialty[30];}Student;typedefstructRoom{introomnum;introomarea;inttotalnum;intstunum;Studentstu[10];Room*next;}Room;typedefstructStory{charstorynum;Room*r
2、oom;}Story;/*-------------------------------------------------------------------------------------------------*/Student*StudentCreat(intage,charname[],charinstitute[],charspecialty[],charsex[]){Student*Stu;Stu=(Student*)malloc(sizeof(Student));Stu->age=age;strcpy(Stu->institute,ins
3、titute);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_nu
4、m;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->
5、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(
6、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;}/*-------------------------------------------------------------------
7、------------------------------*/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*
8、Stu){R=R->next;Student*p;f