c语言显示“illegal else without matching if”是怎么回事?

2025-03-11 05:26:46
推荐回答(1个)
回答1:

if与else不匹配。

计算符号函数的程序,if-else 不匹配造成错误的结果 #include "stdio.h"

void main( )

{int x,y;scanf("%d",&x);y=-1;

if(x!=0)

if(x>0) y=1;

else y=0;

printf("x=%d,y=%d\n",x,y);

}