C语言编程题,求助大佬,谢谢!

2024-11-26 03:28:24
推荐回答(1个)
回答1:

#include "stdio.h"

int main(int argc,char *argv[]){

int g,ch,fh,mh,h;

printf("Enter g(1 or 2), ch(cm), fh(cm) & mh(cm)...\n");

scanf("%d%d%d%d",&g,&ch,&fh,&mh);

if(g<1 || g>2){

printf("Gender error, exit...\n");

return 0;

}

printf("\n%d\n",h=int((g==1 ? (fh+mh)*0.54 : (fh*0.923+mh)/2.0)+0.5));

printf((g-=h)<=3 && g>=-3 ? "OK!\n" : "No!\n"); 

return 0;

}

运行样例和代码图片: