求大佬指点,该如何做
下次建议说明下什么语言实现,或者发布到对应语言板块下哈:
# Python:
weight, height = float(input()), float(input())
print("BMI is %.4f" % (weight/height**2))
# Java:
import java.util.Scanner;
public class BMICalculation {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
double weight = scan.nextDouble();
double height = scan.nextDouble();
double bmi = weight / (height * height);
System.out.printf("BMI is %.4f", bmi);
}
} #include <stdio.h>
#include <stdlib.h>
int main(void)
{
float weight, height, BIM;
printf("体重:");
scanf("%f", &weight);
printf("身高:");
scanf("%f", &height);
BIM = weight/ (height*height);
printf("%.4f\n", BIM);
return 0;
} 本帖最后由 jackz007 于 2022-9-30 23:31 编辑
#include <stdio.h>
int main(void)
{
double h , w ;
scanf("%lf" , & w) ;
scanf("%lf" , & h) ;
printf("BMI is %.4lf\n" , w / h / h) ;
}
编译、运行实况:
D:\\C>g++ -o x x.c
D:\\C>x
43.3
1.27
BMI is 26.8461
D:\\C> jackz007 发表于 2022-9-30 23:30
编译、运行实况:
没权限加好友,也没法私信,等我再混混的吧{:10_254:}
页:
[1]