资源描述:
《宿舍管理系统源代码.doc》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
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*room;}Story
2、;/*-------------------------------------------------------------------------------------------------*/Student*StudentCreat(intage,charname[],charinstitute[],charspecialty[],charsex[]){Student*Stu;Stu=(Student*)malloc(sizeof(Student));Stu->age=age;strcpy(Stu->institute,institute);strcpy(Stu->
3、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=NU
4、LL;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;}returncont
5、rol;}/*-------------------------------------------------------------------------------------------------*/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;}re
6、turnR;}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*
7、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;f