宿舍管理系统源代码.docx

精品word学习资料可编辑 名师归纳总结——欢迎下载 # inclu de<stdi o,h〉 #in clud e〈stdlib,h #i ncludestring,h〉typedefstruc t Stud ent{ char name [20]; char sex [5]; int age ; cha r institute[2 0]; char speci alty[30 ]; }Studen t; typedefstruct Room{ int roomnum; int room area; int totalnum; i nt st unu m; Stu dent stu[10]; Ro om *next; } Room; typed ef struct Story{ cha r st orynum; Room *room; }Story ; /* -——-- ——— --——-—-—-—-—-— ---—--—-- ——— ---—- - -- ---—--- --- ----- ---—-— -——— - ---—- -—-—-- —-—-- —-——- ——— --—--*/ Student *StudentCreat(i nt age,char name[], char inst itute [],char spe cialty[] ,char sex[]) { Stud ent *Stu; Stu=(Stude nt *)mal loc(sizeof(S tuden t)); Stu->a ge=a ge; strcp y(Stu-〉institute,instit ute); strcpy (Stu-〉n ame,na me); st rcpy(Stu->spec ialty, sp ecialty) ; st rcpy( Stu— sex,sex ); return Stu; } Room * RoomC re at(int room_num,in t room_ar ea,i nt total_num, i nt stu_ num) { Roo m *R ; int i; R=(Room *) mal loc(sizeof( Room)); if (.R)return NULL; 精品word学习资料可编辑 名师归纳总结——欢迎下载 R->roomnum=room _num ; R—roomarea=room_area; R-〉t ota lnum=total_num; R-stunum=stu _nu m; R-〉n ex t= NULL ; return R; } Story *Stor yCreat() { Sto ry *S; S=(Story *) mallo c(sizeof(Story) ); S—room=RoomCreat(0, 0,0,0); return S; } St ory * DormCreat() { Story * S, * c ontr ol; char i; control= (Story * )malloc(2 6* sizeof(Stor y)); if(! control) ret urn NULL; 精品word学习资料可编辑 名师归纳总结——欢迎下载 for(i=’ Ai; { =Z’i;++ ) 精品word学习资料可编辑 名师归纳总结——欢迎下载 S= St or yCreat(); S-storynum =i; 精品word学习资料可编辑 名师归纳总结——欢迎下载 control[i —’ A] } =*S; 精品word学习资料可编辑 名师归纳总结——欢迎下载 return control ; } /* - --————— --———— -—————— - --— -—-—-- ---- ---- -- --—---- ---- —--—-- ---——— ---—- -—-------- -—— ----- -—— -—- -——— */ Story * Sto rySe ar ch(S tory *control ,char st orynu m) { re turn control+( storynum- A ’;) } Room * RoomSe arch(Ro om *R ,int ro om_num) { while( R—〉next!=NULL) { if (R-〉n ext->r oomnum= =r oom_nu m)break; else R=R- >next; } retu rn R; } 精品word学习资料可编辑 名师归纳总结——欢迎下载 Student *Stud entSeacr { h (Roo m

文档评论(0)

1亿VIP精品文档

相关文档