《宿舍管理系统源代码》由会员分享,可在线阅读,更多相关《宿舍管理系统源代码(15页珍藏版)》请在金锄头文库上搜索。
1、# i n c 1 u de# n nclud e t ypedefstru c t Stu d ent ch a r nam e 2 0 ;char sex 5;int age ;ch a r institute 20;ch ar sp ec i alty 3 0; Stu den t;t ypedefstru ct Room int roomnum; in t r oom area;int t o ta 1 num ;1 nt st un u m;Stu den t stu 10;R o om * next; Room;typ e d ef struct S tory ch a r st
2、orynu m; Room * r oom;Story;/* - - - - - S t ud e nt * S tud c n t Creat (int age, char name 口 , char i ns t itut e,char sp e cialty口,char sex) S t u d ent *Stu;Stu= (Stu d e nt * )ma 1 loc(sizeof( S tu d ent);Stu a ge= a ge;strcp y (Stu-institu t e, instit u te);strcpy (Stu n ame, n a me);s t rcpy(
3、Stu-spec i a l t y, sp ecialt y );st rcpy (Stusex ,sex );return St u ;Room *RoomCreat (int room_num, i n t room_ar ea, int tot al_num, i nt stu_num)Room * R ;in t i;R=(Room * ) m a 1 l o c(siz e of (Ro o m);if(!R) retu r n NULL;R - room n um=roo m _num ;Rroomarea=r oom_area ;Rt o t a lnum= t otal_nu
4、m;R-stunum=s t u _nu m;R- n ex t= NULL ;retu r n R;Sto r y * St o r yCr e at()Sto ry *S;S= (Story *) m all o c(size o f(Stor y );S ro o m=RoomCreat(O , 0, 0 ,0);return S;S t ory * DormC r eat ()Story * S, * c on t r ol;char i ;co n t rol= (Sto ry *)malloc ( 2 6* sizeo f(Sto r y);i f (! con t rol)re
5、t urn NULL;for (i= Ai storynum =i;c ont r ol i A=* S;return c ontrol;/* - - - - /Stor y St orySear ch (Story * con t rol, char st oryn u m)return c ontrol + ( story n umA;)Room * Room S e arch(R o om *R , int r o om_num)while (Rnext! =NULL)i f (Rn ext- roomn um = = r oom_n u m) break; el se R=R- nex
6、t;retu rn R ;S t u den t * S t u d entSearc h (Ro o m * R ,charn a me口)Stud ent *p;int i;R=R-next;p = R- s tu;for(i=0; i stu num; i+ + )i f(strcmp (p-namc , nam e)= =0) r etu r n p; e 1 se p+ ;retu rn NULL ; * - - - void R o omIn ser t (Sto ry * S ,Room * R)Rnex t =S- room-next;S- room ne x t = R;v
7、oid St udent Insert (Room *R, Stude nt *S t u)R=R next;R-st u Rstun um =*Stu ;Rs tun u m +;vo i d RoomDel e t e(Ro om * R)R o om * p;R = R-next;p=R;R =R n ext;f r ee (p);vo i d S tuden tDelete(Room *R, Stu d e nt * Stu)R = R -nex t ;Stude nt * p;for(p=R stu ; Stu roomnum=k;break;case2:p r in t f (面积
8、:);scanf C%d ,&k);R - roomarea=k;br e ak;case 3:p r intf (可容纳人数:”);s c an f ( % d & k);R total n um =k;break;v o idS tudentRevam p(S t uden t* S tu)in t i, k;ch ar str 30;pr i ntf( 1、姓名 2、性别3、学院4、专业5、年龄n) pri n t f(要修改那一项n” ;)scanf ( d ,&i);sw itc h (i)case 1 :printf。姓名:);sc anf ( % s , s tr);strc p
9、y (Stu- n ame, st r );b r ea k;case 2 :pr i ntf (性别:);scanf(%s t,s );s t rcpy ( S tus ex, st r );break;ca se 3:printf (学院 : );scanf( ” s , str);strcpy (S t u in s tit u te, str);brea k;case 4: p ri n t f (专业:);scan f ( s”,str ;strcpy (Stu spec i a l t y, str); brea k;case 5:prin t f ( 年龄:);scanf( ”
10、d”, &k);Stu- age =k; b reak;/* - - - */voi d RoomS can (Room * R )in t i ;Student * p;R=R-nex t ;p r intf (房号:%dn ,R roomnum);p r i ntf (面积: n,R r oo mare a);p r in t f( 可容纳人数:n,R totalnum);print f ( 已住入人数: n , R- stu num);p rintf( 成员:”);f or(i=0 ; i Rstunum ; i+)p=& ( R- stu i );p r int f ( s ,p A
11、n a me);putchar (n);void Stu dentSca n ( S tuden t * S tu )print f (姓名:sn,S t u-name);pri n tf ( 年龄:%dn ,Stu- age);p r intf(性别:sn, S tu s ex);printf (学院: sn,Stu- institute);p r i n t f (专业:% s n, Stu- speci al t y);in t m ai n ()int roomnum, roomarc a,t o talnum, s tunum, age;i n t event ;char name
12、20 ,institute 2 0,spec i a 1 ty 30,sex5; c har st o ry n um, j udge;S t ory * cont r o l;St o ry *S;Room R;Stud ent * Stu;control=Dorm C r eat (); d opri nt f* * * * * * * * * * * 注意 * * * * * * * n);先录入宿舍信息才能录入学生信息intf(”n” );pr i ntf(先录入信息才能删除浏览或修改信息 * * n”) ;p r in t f (*rintf (n*n );* * * * * * *、n”)宿舍管理系统printf (功能选择菜单: n)p rintf( 1、宿舍信息录入2、学生信息录入3、删除某个宿舍4、删除某个学生n );p r