这是我用xcode写的,还请多指教
#include "stdio.h"
int Male_test(int wei,int hei,int pul,int up)
{
int ratio;
int s1,s2,s3,s4;
ratio=wei/hei;
if (ratio>=17||ratio<23) s1=25;
if (ratio>=23||ratio<=28) s1=20;
if (ratio<17) s1=17.5;
if (ratio>28) s1=15;
if (pul<3000) s2=10.5;
if (pul>=3000||pul<4000) s2=21;
if (pul>=4000||pul<=4800) s2=27;
if (pul>4800) s2=35;
if (up>20) s3=40;
if (up<10) s3=12;
if (up>=10||up<15) s3=24;
if (up>=15||up<=20) s3=32;
s4=s1+s2+s3;
return s4;
}
int Female_test(int wei,int hei,int pul,int up)
{
int ratio;
int s1,s2,s3,s4;
ratio=wei/hei;
if (ratio>=17||ratio<23) s1=25;
if (ratio>=23||ratio<=28) s1=20;
if (ratio<17) s1=17.5;
if (ratio>28) s1=15;
if (pul<2000) s2=10.5;
if (pul>=2000||pul<3000) s2=21;
if (pul>=3000||pul<=3500) s2=27;
if (pul>3500) s2=35;
if (up>60) s3=40;
if (up<25) s3=12;
if (up>=25||up<50) s3=24;
if (up>=50||up<=60) s3=32;
s4=s1+s2+s3;
return s4;
}
int main()
{
int height,weight;
int pulmonary;
int pull_up,sit_up,result;
int gender;
printf("Please choose your gender:\n[1]Male\n[2]Female\n");
scanf("%d",&gender);
switch (gender) {
case 1:
printf("Please the male's weight,height,pulmonary and pull_up\n");
scanf("%d%d%d%d",&weight,&height,&pulmonary,&pull_up);
result=Male_test(weight, height, pulmonary, pull_up);
if (result<60) printf("Unhealth\n");
if (result>80) printf("Health\n");
else printf("Common\n");
break;
case 2:
printf("Please the female's weight,height,pulmonary and sit_up\n");
scanf("%d%d%d%d",&weight,&height,&pulmonary,&sit_up);
result=Male_test(weight, height, pulmonary, sit_up);
if (result<60) printf("Unhealth\n");
if (result>80) printf("Health\n");
else printf("Common\n");
break;
}
return 0;
}