摘要: int Random5(){ return rand() % 5 + 1;}int Random7(){ return rand() % 7 + 1;}int rand7(){ int i; do { i = 5 * (Random5() - 1) + R... 阅读全文
posted @ 2015-04-03 22:14 liuhg 阅读(128) 评论(0) 推荐(0) 编辑
摘要: #include#includeusing namespace std;int Partition(int *A, int p, int r){ int x = A[r]; int i = p - 1; for (int j = p; j < r; j++) { ... 阅读全文
posted @ 2015-04-03 20:57 liuhg 阅读(636) 评论(0) 推荐(0) 编辑
摘要: #includeusing namespace std;int Partition(int *a, int p, int r){ int i = p - 1; int x = a[r]; for (int j = p; j < r; j++) { ... 阅读全文
posted @ 2015-04-03 20:04 liuhg 阅读(294) 评论(0) 推荐(0) 编辑
摘要: #define swap(a,b) (a)=(a)^(b);(b)=(a)^(b);(a)=(a)^(b)这种方法,不能用于同址交换,如a=A[0],b=A[0];原因很简单,因为修改一个就会修改另外一个,它修改的地址里对应的数的值 阅读全文
posted @ 2015-04-03 20:00 liuhg 阅读(448) 评论(1) 推荐(0) 编辑
摘要: 首先两两比较找到最大的元素,需要n-1次,即二叉树的非叶子节点的个数。之后次最大的一定在和最大的元素比较过的元素中,共有lgn-1个,即树的高度。故加起来就是n+lgn-2#includeusing namespace std;class Node{public: Node(); Nod... 阅读全文
posted @ 2015-04-03 16:47 liuhg 阅读(2015) 评论(0) 推荐(0) 编辑
摘要: #includeusing namespace std;void getMaxMin(int a[], int len){ int max, min; if (len % 2) { max = min = a[0]; for (int i = 1; i ... 阅读全文
posted @ 2015-04-03 12:09 liuhg 阅读(278) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 #include 3 using namespace std; 4 //数值型基数排序 5 int getDigit(int num, int index) 6 { 7 int mod = 1; 8 while (index) 9 ... 阅读全文
posted @ 2015-04-03 08:13 liuhg 阅读(411) 评论(0) 推荐(0) 编辑
摘要: Installation From Nsnam Jump to: navigation, search Main Page - Current Development - Developer FAQ - Tools - Related Projects - Project Ideas - Summ... 阅读全文
posted @ 2014-11-16 09:28 liuhg 阅读(874) 评论(0) 推荐(0) 编辑
摘要: In order to build the code on ns-3 refer to the following steps:Download ns-3 from http://www.nsnam.org/Install ns-3 by following the instructions in ... 阅读全文
posted @ 2014-11-16 09:09 liuhg 阅读(1894) 评论(1) 推荐(0) 编辑
摘要: android程序连接网络出现android.os.NetworkOnMainThreadEx错误:android.os.NetworkOnMainThreadExceptionat android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(St... 阅读全文
posted @ 2014-10-20 10:04 liuhg 阅读(1315) 评论(0) 推荐(0) 编辑