该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
#include
#include
#include
#include
void menu(){
char flag;
void height(char choice);
void BMI();
system("title 身高体型判定系统");
system("color 7e");
while(1){
system("cls");
printf("******************************\n");
printf("1、求男孩身高\n");
printf("2、求女孩身高\n");
printf("3、预测体型\n");
printf("4、退出系统\n");
printf("******************************\n");
flag = getchar();
getchar();
if(flag=='1'){
height(flag);
}else if(flag=='2'){
height(flag);
}else if(flag=='3'){
break;
} else if(flag=='4'){
//exit(0);
//return;
}else{
printf("您输入错误,请重新输入!\n");
}
Sleep(5000);
}
}
void height(char choice){
double fatherheight;
double motherheight;
double boyheight;
double girlheight;
printf("请输入父亲身高和母亲身高,输入格式为:(?,?),单位为米\n");
scanf("%lf,%lf",&fatherheight,&motherheight);
getchar();
printf("父亲的身高为:%.2f米\n",fatherheight);
printf("母亲的身高为:%.2f米\n",motherheight);
if(choice==1){
boyheight = (fatherheight + motherheight)*1.08/2;
printf("男孩身高:%.2f\n",boyheight);
}else if(choice==2){
girlheight = (fatherheight + 0.923*motherheight)/2;
printf("女孩身高:%.2f\n",girlheight);
}
}
void BMI(){
double bmi;
double height;
double weight;
printf("请输入您自个儿的身高体重,输入格式为(kg,m)\n");
scanf("%lf,%lf",&height,&weight);
getchar();
bmi=weight/(height*height);
printf("BMI=%f\n",bmi);
if(bmi<=18.4){
printf("体型偏瘦,需补充营养\n");
}else if(bmi>18.4&&bmi<=23.9){
printf("营养均衡,正好\n");
}else if(bmi>23.9&&bmi<=27.9){
printf("体型偏重,注意饮食\n");
}else if(bmi>27.9){
printf("过胖会有烦恼的\n");
}
}
int main(int argc, char *argv[])
{
BMI();
return 0;
}