2014/4/9 2014/4/9

 #include<stdio.h>

#include<stdlib.h>
#include<math.h>
 
main()
{
 
struct student
 
{
 
int id;
 
float h;
 
int w;
float bmi;
 
};
 
 
struct student a, b, c ,d;
 
 
a.h=1.5;
a.w=50;
a.bmi=(a.w/pow(a.h,2));
b.h=1.6;
b.w=55;
b.bmi=(b.w/pow(b.h,2));
c.h=1.7;
c.w=60;
c.bmi=(c.w/pow(c.h,2));
d.h=1.8;
d.w=65;
d.bmi=(d.w/pow(d.h,2));
 
printf("%.2f\n",(a.bmi+b.bmi+c.bmi+d.bmi)/4);
 
system("pause");
 
}
 
網頁文章 網頁文章

 #include<stdio.h>

#include<stdlib.h>
#include<math.h>
 
main()
{
 
typedef struct student
 
{
 
int id;
 
float h;
 
int w;
float bmi;
 
};
 
 student a;
 
scanf("%f %d",&a.h,&a.w);
a.bmi=(a.w/pow(a.h,2));
 
 
printf("%.2f\n",a.bmi);
 
system("pause");
 
}