2013年3月9日

【面试题】计算整数符号

摘要: 题目:计算一个整数的符号位int v; // we want to find the sign of vint sign; // the result goes here不能使用函数,不能使用if,不能使用“?:”三目运算符…总而言之,本题主要考查的是“位操作、逻辑操作、关系操作”。在google里面输入“Compute the sign of an integer”,搜到一篇强文,里面也包括了这道题目的答案。地址:http://graphics.stanford.edu/~seander/bithacks.html这里把文中关于本题的解答引用如下:Compute the sig... 阅读全文

posted @ 2013-03-09 20:26 zhuyf87 阅读(472) 评论(0) 推荐(0) 编辑

导航