在以下C程序中
#include<stdio.h>
int main()
{
int a,b;
printf("Enter the values of a and b : ");
scanf("%d %d",&a,&b);
printf("%d %d",a,b);
return 0;
}
如果我给出值&#34; 3.2,&#34;我得到的答案是= 3 1 有人可以解释一下发生了什么吗?我正在使用DEV C ++编译器。
答案 0 :(得分:2)
函数scanf
正在尝试读取两个int
值。您为3.2
提供了3
,并在a
中显示.
,并停留在.2
。
然后尝试将b
读入.
但却失败,因为whitespace
不被视为b
。
因此永远不会设置1
,函数返回int b=42
以显示转换为1的输入。
您可以通过初始化scanf
来展示这一点,然后在b
之后发现42
仍然是SELECT * FROM x WHERE a = 1 AND b = 2 AND c = 3
UNION ALL
SELECT * FROM x
WHERE
a = 1 AND b = 2 AND c = 0
AND NOT EXISTS (SELECT * FROM x WHERE a = 1 AND b = 2 AND c = 3)
UNION ALL
SELECT * FROM x
WHERE a = 1 AND b = 0 AND c = 0
AND NOT EXISTS (SELECT * FROM x WHERE a = 1 AND b = 2 AND c = 3)
AND NOT EXISTS (SELECT * FROM x WHERE a = 1 AND b = 2 AND c = 0)
。