易错的if语句
#include <stdio.h>
int main()
{
int a=20;
if (1 <= a <= 10)//1<=20为真,结果为1,1<=10为真
{
printf("in range\n");
}
else
{
printf("out of range\n");
}
return 0;
}
结果:
in range
请按任意键继续. . .
时间: 2024-10-08 10:17:02
易错的if语句
#include <stdio.h>
int main()
{
int a=20;
if (1 <= a <= 10)//1<=20为真,结果为1,1<=10为真
{
printf("in range\n");
}
else
{
printf("out of range\n");
}
return 0;
}
结果:
in range
请按任意键继续. . .