c语言体型判定系统bmi,这串代码为什么只能运行一小段,求大佬解惑

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

#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;

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值