随笔分类 - 排序算法
摘要:#include <iostream> //#include <vector> using namespace std; class merge { public: merge() { } void mergeadd(int arr[],int left,int mid,int right,int
阅读全文
摘要:int partition(int arr[], int low, int high) { int i = low; int j = high; int base = arr[low]; if (low < high) { while (i < j) { while (i < j && arr[j]
阅读全文
摘要:插入排序: int main(void) { int beauties[] = { 2, 1, 4, 6, 8, 5, 9, 7, 5 }; int len = sizeof(beauties) / sizeof(beauties[0]); int preindex = 0, current = 0
阅读全文
摘要:#include <iostream> using namespace std; int main(void) { int beauties[] = { 2, 1, 4, 6, 8, 5, 9, 7, 5 }; int len = sizeof(beauties) / sizeof(beauties
阅读全文
摘要:使用指针交换数据 void swap(int* num1, int* num2) { int test; test = *num1; *num1 = *num2; *num2 = test; } 非指针交换并排序(低到高) void lowtoheight(int height[],int len)
阅读全文