PhoenixZq
分享是一门艺术~~
摘要: #include <iostream>#include <vector>using namespace std;inline int leftChild(int i){ return 2*i+1;}template <typename Comparable>void percDown(vector<Comparable>& a,int i,int n){ int child; Comparable tmp; for(tmp = a[i];leftChild(i) < n;i = child) { child = leftChild( 阅读全文
posted @ 2011-09-25 22:07 PhoenixZq 阅读(260) 评论(0) 推荐(0) 编辑
摘要: 位运算应用口诀清零取反要用与,某位置一可用或若要取反和交换,轻轻松松用异或移位运算要点 1 它们都是双目运算符,两个运算分量都是整形,结果也是整形。 2 "<<" 左移:右边空出的位上补0,左边的位将从字头挤掉,其值相当于乘2。 3 ">>"右移:右边的位被挤掉。对于左边移出的空位,如果是正数则空位补0,若为负数,可能补0或补1,这取决于所用的计算机系统。 4 ">>>"运算符,右边的位被挤掉,对于左边移出的空位一概补上0。位运算符的应用 (源操作数s 掩码mask)(1) 按位与-- &am 阅读全文
posted @ 2011-09-25 13:03 PhoenixZq 阅读(266) 评论(0) 推荐(0) 编辑