摘要: /* * 获取数组a中最大值 * * 参数说明: * a -- 数组 * n -- 数组长度 */ private int GetMax(int[] a) { int max; max = a[0]; for (int i = 1; i < a.Length; i++) if (a[i] > max 阅读全文
posted @ 2017-06-03 10:07 Sempron2800+ 阅读(168) 评论(0) 推荐(0) 编辑
摘要: /* * (最大)堆的向下调整算法 * * 注:数组实现的堆中,第N个节点的左孩子的索引值是(2N+1),右孩子的索引是(2N+2)。 * 其中,N为数组下标索引值,如数组中第1个数对应的N为0。 * * 参数说明: * a -- 待排序的数组 * start -- 被下调节点的起始位置(一般为0, 阅读全文
posted @ 2017-06-03 10:06 Sempron2800+ 阅读(150) 评论(0) 推荐(0) 编辑
摘要: public void SelectSort(int[] ary) { // 需要遍历获得最小值的次数 for (int i = 0; i < ary.Length - 1; i++) { int temp = 0; int index = i; // 用来保存最小值得索引 //在后面的序列中,寻找 阅读全文
posted @ 2017-06-03 09:38 Sempron2800+ 阅读(200) 评论(0) 推荐(0) 编辑