- 1、本文档共11页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
# inclu de<stdi o、h〉#in clud e〈
# inclu de<stdi o、h〉
#in clud e〈stdlib、h
#i ncludestring、h〉t ypedef struc t Stud ent{
char name [20] ;
char
sex [5] ;
int age ;
cha r institute[2 0];
char
speci alty[30 ];
}Studen t;
t ypedef struct 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 *S tudentCreat(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 ial ty, sp ecialty) ; st rcpy( Stu— sex,sex );
return Stu;
}
Room * RoomC re at(int room_num,in t
i nt stu_ num)
{
Roo m *R ; int i;
room_ar ea,i nt total_num,
R=(Room
*) mal loc(sizeof( Room));
if (.R)return NULL;
R->roomnum=room _num ;R—roomarea=room_area; R-〉t
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; for(i= ’ Ai; =Z’i;++ )
{
S= St or yCreat(); S-storynum =i; control[i —’ A] =*S;
}
return
control ;
}
/* - --————— -- ———— -—————— - --— -—-—-- ---- ---- --
- -—---- ---- —--—-- -- -——— ---—- -— -------- -—— ----- -—— -—-
- ——— */
Story * Sto rySe ar ch(S t ory *control ,char
{
re turn control+( storynum- A ’;)
}
Room * RoomSe arch(Ro om *R ,int ro om_num)
{
while( R—〉next!=NULL)
{
st orynu m)
if (R-〉n ext->r oomnum= =r oom_nu m)break;
else R=R- >next;
}
retu rn
R;
}
S tudent{*Stud entSea
S tudent
{
*Stud entSeacr h (Roo m * R,char na me[])
Stud ent *p;
int i; R=R-next;
p= R->s tu;
for(
文档评论(0)