各位大哥小弟刚学…问题有点低级不要见笑啊。
int main(void)
{
char sex,sports,diet ;
int a,b;
float hf,hm,hc ;
printf(“please input hf and hm\n”);
scanf (“%f%f”,&hf,&hm);
printf(“you are man or women?\n man input’M'women input’F'\n”) ;
scanf(“%c”,&sex);
if (sex==’M') hc=(hf+hm)*0.54 ;
else hc=(hf*0.923+hm)/2;
printf (“Do you like physicd execise it?input ‘y’or’n'” );
scanf (“%c”,&sports);
if (sports==’y')hc*=1.02;
printf (“Do you have good eating habits?input ‘y’or’n'” ) ;
scanf(“%c”,&diet);
if (diet==’y')hc*=1.015;
printf(“hc=%f”,hc) ;
getch();
return 0;
}
这3个scanf 为什么有2个是没用的
程序运行时
想问下哪里错了?
#include
#include “Conio.h”
int main(void)
{
char sex,sports,diet ;
float hf,hm,hc ;
printf(“please input hf and hm\n”);
scanf (“%f%f”,&hf,&hm);
printf(“you are man or women?\n man input’M'womeninput’F'\n”) ;
sex=getch();
if (sex==’M') hc=(hf+hm)*0.54 ;
else hc=(hf*0.923+hm)/2;
printf (“Do you like physicd execise it?input ‘y’or’n'\n” );
sports=getch();
if (sports==’y')hc*=1.02;
printf (“Do you have good eating habits?input ‘y’or’n'\” ) ;
diet=getch() ;
if (diet==’y')hc*=1.015;
printf(“hc=%f”,hc) ;
getch();
return 0;
}
这个是改过的…
好像对的