(1)标准体重=(身高-110)公斤; (2)超过标准体重5公斤为过胖; (3)低于标准体重5公斤为过瘦。 例如:输入身高和体重分别为160,60,输出为过胖 输入身高和体重分别为160,50,输出为标准 输入身高和体重分别是160,40,输出为过瘦
代码如下:
#include <stdio.h>
int main()
{
int h,w;
printf("请输入身高(厘米)和体重(公斤)");
scanf("%d %d",&h,&w);
int s = h - 110;
if( (w-s) > 5)
printf("过胖\n");
else if( s - w > 5)
printf("过瘦");
else if(s - w == 0)
printf("标准\n");
//getchar();
//getchar();
return 0;
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp2
{
class Program
{
static void Main(string[] args)
{
double high;
double weight;
double StandardWeight = 0; //定义变量,赋值
System.Console.Write("请输入你的身高:");
high = double.Parse(Console.ReadLine()); //获取身高
System.Console.Write("请输入你的体重:");
weight = double.Parse(Console.ReadLine()); //获取体重
StandardWeight = high - 110; //计算获得标准身高
double delta = weight - StandardWeight; //计算差值
if (delta > 5)
System.Console.Write("过重");
else if (delta < -5)
System.Console.Write("过瘦");
else
System.Console.Write("正常"); //判断是否正常
Console.ReadKey();
}
}
}