-2

current 和 stored 都是 16 位变量。问题是当存储为 65535 且电流为 3 时,此条件将失败,因为答案是否定的。

stored=current; 

if(stored==0)
{
    process the condition;
}          

else if(current-stored>3)
{
    process the condition;
}
else 
{
    reject;
}

如何检查这种情况?

4

1 回答 1

0

正如你所拥有的

stored=current; 

那么这个条件总是假的

current-stored>3

因此,如果stored为零,则您做生意,否则拒绝

编辑

为什么不阅读作业问题

删除stored=current- 你为什么把它放进去?

有一个 if 语句

if (stored  == 65535 && current == 3) {
   .. reject 
} else {
   .. process condition
}

如果您愿意,您可以使用 de-morgans law 来交换那些

于 2013-11-08T06:31:42.167 回答