输入身高、体重、性别,判断是否是标准体重,男性标准=(身高-100)+-3,女性标准=(身高-110)+-3

Console.WriteLine("请输入身高");
int hight = int.Parse(Console.ReadLine());
Console.WriteLine("请输入体重");
int weight = int.Parse(Console.ReadLine());
Console.WriteLine("请输入性别");
string sex = Console.ReadLine();
if (sex == "男")
{
int a = hight - 100;
if (weight > (a + 3))
{
Console.WriteLine("不是标准体重,偏胖");
}
else if (weight <= (a + 3) && weight >= (a - 3))
{
Console.WriteLine("是标准体重");
}
else
Console.WriteLine("不是标准体重,偏瘦");
Console.ReadLine();
}
else if (sex == "女")
{
int a = hight - 110;
if (weight > (a + 3))
{
Console.WriteLine("不是标准体重,偏胖");
}
else if (weight <= (a + 3) && weight >= (a - 3))
{
Console.WriteLine("是标准体重");
}
else
Console.WriteLine("不是标准体重,偏瘦");
}
else
Console.WriteLine("请输入正确的性别");
Console.ReadLine();

你可能感兴趣的:(判断)