#includestdio.h#includestdlib.h#includeconio.hintINDEX[32];structstudent{intnum;charname[21];intage;inthigh,weight;}students[32];voidpage_title(char*menu_item){printf(\n==================学生健康管理系统=====================\n\n%s\n\n,menu_item);}//voidreturn_confirm(void){printf(\n按任意键返回......\n);getch();}//voidstudent_new(void){intn;page_title(录入学生基本信息);for(n=0;n32;n++)if(students[n].num==0)break;printf(学号:);scanf(%d,&students[n].num);printf(姓名:);scanf(%s,&students[n].name);printf(年龄:);scanf(%d,&students[n].age);return_confirm();}//////////////////////////////////////////////////////////////////////intsearch_num(void){intn,i;printf(请输入学生学号:);scanf(%d,&i);for(n=0;n32;n++){if(students[n].num==i&&students[n].num!=0){printf(学号:%d\n,students[n].num);printf(姓名:%s\n,students[n].name);printf(年龄:%d\n,students[n].age);returnn;}}printf(\n输入错误或学号不存在.\n);return-1;}//////////////////////////////////////////////////////////////////////////////////////////////////voidstudent_del(void){intn;page_title(注销学生基本信息);if((n=search_num())!=-1)students[n].num=0;printf(\n!该学生已注销.\n);return_confirm();}/////////////////////////////////////////////////////////////////////////////////voidstudent_edit(void){intn;page_title(======编辑学生基本信息======);if((n=search_num())!=-1){printf(\n请重新输入新信息:\n学号:);scanf(%d,&students[n].num);printf(姓名:);scanf(%s,&students[n].name);printf(年龄:);scanf(%d,&students[n].age);}return_confirm();}////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////voidscore_input(void){ints,n,t;page_title(======录入体检结果======);printf(\n请用数字键选择项目\n1-身高2-体重\n);scanf(%d,&s);for(n=0;n32;n++){if(students[n].num!=0){printf(\n学号:%d姓名:%s此项数据为:,students[n].num,students[n].name);scanf(%d,&t);switch(s){case1:students[n].high=t;break;case2:students[n].weight=t;break;}}}return_confirm();}/////////////////////////////////////////////////////////voidscore_edit(void){intn;page_title(修改);if((n=search_num())!=-1){printf(身高:%d体重:%d\n,students[n].high,students[n].weight);printf(\n请重新输入:\n身高:);scanf(%d,&students[n].high);printf(体重:);scanf(%s,&students[n].weight);}return_confirm();}/////////////////////////////////////////////////////////////////voidsort_it(charnn){intn,m,p,x,t[32];for(n=0;n32;n++){switch(nn){case'1':t[n]=students[n].num;break;case'2':t[n]=students[n].high;break;case'3':t[n]=students[n].weight;break;}}for(n=0;n32;n++){x=0;p=-1;for(m=0;m32;m++){if(t[m]x){x=t[m];p=m;}}t[p]=-1;INDEX[n]=p;}}//voidbrowser(void){intn,x;chark;sort_it('1');while(1){page_title(======浏览======);printf(按数字键选择排序方式或按0返回\n);printf(学号\t姓名\t年龄\t身高cm\t体重Kg\n);for(n=0;n32;n++){if(INDEX[n]!=-1){x=INDEX[n];printf(\n%d\t%s\t,students[x].num,students[x].name);printf(%d\t%d\t%d\t,students[x].age,students[x].high,students[x].weight);}}k=getch();if(k'6'&&k'0')sort_it(k);elseif(k=='0')break;elsecontinue;}}///////////////////////////voidtest(void){floatzhishu;intn,i;printf(\n请输入学生学号:\n);scanf(%d,&i);for(n=0;n32;n++)if(students[n].num==i){zhishu=students[n].weight/(students[n].high*students[n].high/10000);if(zhishu20&&zhishu25){printf(\n恭喜!您的体重正常,继续保持哦~);}if(zhishu20){printf(\n偏瘦,需要增加饮食!);}if(zhishu25){printf(\n有点胖了哦,注意锻炼~);}}else{printf(\n错误,没有改学生!);break;}return_confirm();}voidmain(void){system(colorf0);menu:page_title(============================操作选单==============================);printf(\n=======请您选择操作========\n);printf(\n==\n);printf(\n=-1-录入学生基本信息=\n);printf(\n=-2-修改学生基本信息=\n);printf(\n=-3-注销学生基本信息=\n);printf(\n=-4-录入体检数据=\n);printf(\n=-5-修改体检数据=\n);printf(\n=-6-浏览数据=\n);printf(\n=-7-健康测试=\n);printf(\n=-0-退出=\n);printf(\n=======================);switch(getch()){case'1':student_new();break;case'2':student_edit();break;case'3':student_del();break;case'4':score_input();break;case'5':score_edit();break;case'6':browser();break;case'7':test();break;case'0':exit(0);}system(cls);gotomenu;}