問題描述是近年來的壹種國際流行的標準體重測定法,可以作為衡量人體肥胖程度的指標。
BMT的計算公式為:體重/身高^2(體重的單位為千克,身高的單位為米)。請妳編寫壹個程序,
輸入某人的身高和體重,程序即可計算出他/她的身高體重指數。*/
//code:
#?include<stdio.h>
#?include<stdlib.h>
int?main(void)
{
float?weight,height;?//體重,身高
float?BMT;
printf("請輸入身高(米):");
scanf("%f",&height);
printf("請輸入體重(千克):");
scanf("%f",&weight);
BMT=weight/(height*height);
printf("BMT=%f\n",BMT);
system("pause");
return?0;
}/*2.和差問題(number.cpp/c/pas)
問題描述變量a和b的差與和分別為4和8,計算並輸出這兩個數。*/
//兩個數的和為8,可知兩個數皆在10以內,可采用窮舉法求出。
//code:
#?include<stdio.h>
#?include<stdlib.h>
int?main(void)
{
int?i,j;
for(i=0;i<10;i++)
for(j=0;j<10;j++)
{
if(((i-j)==4)&&((i+j)==8))
{
printf("兩個數分別為:%d?%d\n",i,j);
}
}
system("pause");
return?0;
}