#include <stdio.h>
int main() {
int select, flag = 0;
float height, weight, bmi;
while (flag != -1) {
printf("\n请输入数字选择功能:\n1. 身高预测\n2. 体型判定\n");
scanf("%d", &select);
switch (select) {
case 1:
printf("\n请输入体重(单位:千克):");
scanf("%f", &weight);
height = 1.7 + (weight - 60) / 10.0 * 0.15;
printf("预测身高为:%.2f米\n", height);
break;
case 2:
printf("\n请输入身高(单位:米):");
scanf("%f", &height);
printf("请输入体重(单位:千克):");
scanf("%f", &weight);
bmi = weight / (height * height);
if (bmi < 18.5) {
printf("您的BMI指数为:%.2f,体重过轻。\n", bmi);
} else if (bmi < 24) {
printf("您的BMI指数为:%.2f,体重正常。\n", bmi);
} else if (bmi < 28) {
printf("您的BMI指数为:%.2f,体重过重。\n", bmi);
} else if (bmi < 32) {
printf("您的BMI指数为:%.2f,肥胖。\n", bmi);
} else {
printf("您的BMI指数为:%.2f,严重肥胖。\n", bmi);
}
break;
default:
printf("\n无效选择,请重新输入。\n");
break;
}
printf("\n是否继续使用?(Y/N)");
char choice;
scanf(" %c", &choice);
if (choice == 'N' || choice == 'n') {
flag = -1;
}
}
printf("\n谢谢使用,再见!\n");
return 0;
}