✔ 最佳答案
#include<stdio.h>
#include<stdlib.h>
#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<MAX;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;
}