摘要: #define LeftChild(i)(2 * (i) + 1)void PercDown(int a[], int i, int n){ int c, t; for(t = a[i]; LeftChild(i) < n; i = c) { c = LeftChild(i); if(c != n - 1 && a[c + 1] > a[c]) c++; if(t < a[c]) a[i] = a[c]; else break; } a[i] ... 阅读全文
posted @ 2013-01-20 17:07 ChobitsSP 阅读(162) 评论(0) 推荐(0)
摘要: //插入排序void InsertionSort(int a[], int n){ int i, j, t; for(i = 1; i < n; i++) { t = a[i]; for(j = i; j > 0 && a[j - 1] > t; j--) a[j] = a[j - 1]; a[j] = t; }}template <typename T>void swap(T *x, T *y){ T temp; temp = *x; *x = *y; *y = temp;}//三数中值分割方法int Median3(int a[], int l 阅读全文
posted @ 2013-01-18 11:23 ChobitsSP 阅读(148) 评论(0) 推荐(0)