键盘输入自己的腰围和体重,根据以下身体脂肪含量的计算公式编程计算出自己的脂肪含量,看看自己的脂肪含量是否在正常值范围内,并输出相应的信息如”正常、完美身材等”。
A=腰围(英寸)*4.15 (1英寸=2.54cm)
B=体重(磅)*0.082 (1公斤=2.2磅)
脂肪含量=(A-B-76.76)*1%
(男性正常脂肪含量是12%-20%;女性正常脂肪含量是20%-30%,23%是公认的完美身材脂肪比例。)
#include<stdio.h>
void main()
{ float A,B,weight,waistline,fattiness; char S;
printf(“please input your sex,weight,and waistline”);
scanf (“%c%f%f”,&S,&weight,&waistline);
A=waistline*4.15;
B=weight*0.082;
fattiness=(A-B-76.76)*0.01;
switch(S)
{
case ‘F’:
if(weight*0.2<=fattiness&&fattiness<=weight*0.3)
{ if(fattiness==weight*0.23) printf(“Your stature is perfect”);
else printf(“Your stature is normal”);
}
else printf(“You need more exersice”);break;
case ‘B’:
if(weight*0.12<=fattiness&&fattiness<=weight*0.2)
printf(“Your stature is normal”);
else printf(“You need more exersice”);
}
getch();
}
暂无评论内容