上一页 1 ··· 11 12 13 14 15
摘要: void merge1(int *a,int left,int mid,int right){ int n1=mid-left+1; int n2=right-mid; int *arr1=new int[n1]; int *arr2=new int[n2]; for(int i=0;i<n1;i++) arr1[i]=a[left+i]; for(int i=0;i<n2;i+... 阅读全文
posted @ 2019-03-22 10:16 赵钱富贵 阅读(263) 评论(0) 推荐(0) 编辑
摘要: void swap(int *a,int *b){ int temp=*a; *a=*b; *b=temp; } void BubbleSort(int *a,int length){ for(int i=0;ia[j+1]) swap(a+j,a+j+1); } } } 阅读全文
posted @ 2019-03-21 22:36 赵钱富贵 阅读(87) 评论(0) 推荐(0) 编辑
摘要: 常用的内部排序方法有:交换排序(冒泡排序、快速排序)、选择排序(简单选择排序、堆排序)、插入排序(直接插入排序、希尔排序)、归并排序、基数排序(一关键字、多关键字)。 一、冒泡排序: 1.基本思想: 两两比较待排序数据元素的大小,发现两个数据元素的次序相反时即进行交换,直到没有反序的数据元素为止。 阅读全文
posted @ 2019-03-20 12:41 赵钱富贵 阅读(913) 评论(0) 推荐(0) 编辑
摘要: void swap(int *a,int *b){ int temp=*a; *a=*b; *b=temp; } void selectSort(int *a,int n){ for(int i=0;i<n-1;i++){ int min=i; for(int j=i+1;j<n;j++){ if( 阅读全文
posted @ 2019-03-20 12:15 赵钱富贵 阅读(101) 评论(0) 推荐(0) 编辑
摘要: void insertionSort(int *a,int n){ for(int i=1;i=0&&a[j]>key){ a[j+1]=a[j]; j--; } a[j+1]=key; } } 阅读全文
posted @ 2019-03-20 08:20 赵钱富贵 阅读(64) 评论(0) 推荐(0) 编辑
摘要: void ShellSort(int *a,int length){ int gap=length/2; while(gap>=1){ //插入排序思想 gap替换1 for(int i=gap;i=0&&a[j]>temp){ a[j+gap]=a[j]; j=j-gap; } a[j+gap]=temp; } gap... 阅读全文
posted @ 2019-03-15 17:31 赵钱富贵 阅读(80) 评论(0) 推荐(0) 编辑
上一页 1 ··· 11 12 13 14 15