无效操作代码在main 函数中

来源:百度知道 编辑:UC知道 时间:2024/06/25 05:30:53
#include "stdio.h"
#include "conio.h"

main()
{
int high,weight,sex,standard;
scanf("%d,%d,%d",&sex,&high,&weight);/*1,162,50*/
if (sex==1)
{
standard=high-105;
if (weight-standard<=2)
printf("yes");
else (weight-standard>2);
printf("no");
}
else (sex==0);
{
standard=high-110;
if (weight-standard<=2)
printf("yes");
else(weight-standard>2);
printf("no");
}
getch();
}
这个程序是用来判断男女身材是否标准的...
现在遇到一个问题
程序执行了if后还继续执行else,而且提示了else后面括号是"无效操作代码在main 函数中",如果我改了else if就没有这个警告,但是照样会执行ele if的语句,这是怎么回事,在两太电脑上面都一样...
其实如果我把else后面的语句删除了,结果就不会出错,也不会执行else后面的语句,但是这道题刚刚好是要这样要求的...
请问这是怎么了?编译器出问题了吗?不可能3个编译器同时有问题吧?
麻烦各位了...

没见过你这种写法,else后面不能直接跟一个判断式,你又加了分号,这行的时候这句就根本没用。

#include "stdio.h"
#include "conio.h"

main()
{
int high,weight,sex,standard;
scanf("%d,%d,%d",&sex,&high,&weight);/*1,162,50*/
if (sex==1)
{
standard=high-105;
if(weight-standard<=2) printf("yes\n");
else printf("no\n");
}
else
{
standard=high-110;
if (weight-standard<=2) printf("yes\n");
else printf("no\n");
}
getch();
}