English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
所有分類

有人會解嗎?? 幫個忙吧
1.要求使用者輸入三個人的身高
2.計算其平均身高與總身高並顯示出來
第二題
要求使用者輸入身高體重,並且計算BMI值

2007-09-30 10:05:52 · 1 個解答 · 發問者 7 in 電腦與網際網路 程式設計

1 個解答

#include
#include
#define MAX 3
double bmi(double Weight, double Height){
return Weight/(Height*Height);
}
int main(int argc, char* argv[]){
//=====START=====//
int opt,i;
double h,w,total=0;
printf("Input option (1/2): "),scanf("%d",&opt);
switch(opt){
case 1:
for(i=0;i printf("Input %d Height (CM): ",i+1),scanf("%lf",&h);
total+=h;
}
printf("Average Height= %lf\nTotal Height= %lf\n",total/MAX,total);
break;
case 2:
printf("Input Weight (KG): "),scanf("%lf",&w);
printf("Input Height (M): "),scanf("%lf",&h);
printf("SI units bmi is %lf\n",bmi(w,h));
break;
default:
break;
}
//=====END=====//
system("PAUSE");
return 0;
}

2007-09-30 11:43:13 · answer #1 · answered by Big_John-tw 7 · 0 0

fedest.com, questions and answers