宿舍管理系统源代码
精品文档---下载后可任意编辑 #include〈stdio。h> #include〈stdlib。h> #include〈string。h> typedefstruct Student{ char name[20]; char sex[5]; int age; char institute[20]; char specialty[30]; }Student; typedefstruct Room{ int roomnum; int roomarea; int totalnum; int stunum; Student stu[10]; Room *next; }Room; typedefstruct Story{ char storynum; Room *room; }Story; /*——-——--——-—-——--—-—-—-——-—-———-—————-——--———————————-—————————-——-——---————-——--———--——-————--———*/ Student *StudentCreat(int age,char name[],char institute[],char specialty[],char sex[]) { 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); return Stu; } Room *RoomCreat(int room_num,int room_area,int total_num,int stu_num) { Room *R; int i; R=(Room *)malloc(sizeof(Room)); if(!R)return NULL; R—>roomnum=room_num; R-〉roomarea=room_area; R-〉totalnum=total_num; R-〉stunum=stu_num; R-〉next=NULL; return R; } Story *StoryCreat() { Story *S; S=(Story *)malloc(sizeof(Story)); S->room=RoomCreat(0,0,0,0); return S; } Story *DormCreat() { Story *S,*control; char i; control=(Story *)malloc(26*sizeof(Story)); if(!control)return NULL; for(i=’A ;inext—〉roomnum==room_num)break; else R=R-〉next; } return R; } Student *StudentSearch(Room *R,char name[]) { Student *p; int i; R=R—>next; p=R—〉stu; for(i=0;iname,name)==0)return p; else p++; } return NULL; } /*--——-——————-——-—————————-——--————-—-——---——-—-——---————--—--—-———-—————————--—-------——————--———-*/ void RoomInsert(Story *S,Room *R) { R->next=S—〉room—〉next; S-〉room—>next=R; } void StudentInsert(Room *R,Student *Stu) { R=R—〉next; R—〉stu[R—〉stunum]=*Stu; R—>stunum++; } void RoomDelete(Room *R) { Room *p; R=R—〉next; p=R; R=R—>next; free(p); } void StudentDelete(Room *R,Student *Stu) { R=R—>next; Student *p; for(p=R->stu;Stustunum—-; } void RoomRevamp(Room *R) { int i,k; R=R—>next; printf(”1、房号 2、面积 3、可容纳人数:\n”); printf(“要修改那一项:\n”); scanf(“%d”,&i); switch(i) { case 1:{ printf(”房号:“); scanf(“%d”,&k); R—〉roomnum=k; break; } case 2