c – 比较两个整数,无任何比较
发布时间:2020-12-16 05:32:37 所属栏目:百科 来源:网络整理
导读:没有比较可以找到最大的两个整数吗?我找到了一些解决方案: if(!(a/b)) // if a is less than b then division result will be zero.{ cout " b is greater than a";}else if (!(a-b)) // we know a is greater than or equal to b now. check whether they
没有比较可以找到最大的两个整数吗?我找到了一些解决方案:
if(!(a/b)) // if a is less than b then division result will be zero. { cout << " b is greater than a"; } else if (!(a-b)) // we know a is greater than or equal to b now. check whether they are equal. { cout << "a and b are equal"; } else cout << "a is greater than b"; 但是如果(c)或if(!c)与零的比较.另外它不负责负数.其实我需要一个解决方案来避免任何if语句.而应该使用switch语句和算术运算符.感谢名单. 解决方法
减去他们,并使用令人讨厌的微小黑客攻击检查标志
http://graphics.stanford.edu/~seander/bithacks.html 如果其他程序员知道你住在哪里,不要在生产代码中执行此操作. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |