根据the c program 一书中源代码来测试shell排序法
来源:互联网 发布:邢台学院教务处网络 编辑:程序博客网 时间:2024/05/16 15:51
原理:shell排序的思想是根据步长由长到短分组,进行排序,直到步长为1为止,属于插入排序的一种。
关于动画演示可以查看点击打开链接
#include<iostream>using namespace std;int main(){void shellsort(int a[], int n);int a[10] ={9,3,4,5,8,1,6,2,7,0};shellsort(a, 10);for (int i=0; i<=9;i++){cout<<a[i]<<' ';}cout<<endl;return 0;}void shellsort(int v[], int n){int gap, i , j, temp;for (gap = n/2; gap > 0; gap /= 2){for (i=gap; i < n; i++){for(j=i-gap; j>=0 && v[j]>v[j+gap]; j-=gap){temp=v[j];v[j]=v[j+gap];v[j+gap]=temp;}}}}// /* shellsort: sort v[0]...v[n-1] into increasing order */// void shellsort(int v[], int n)// {// int gap, i, j, temp;// for (gap = n/2; gap > 0; gap /= 2)// {// for (i = gap; i < n; i++)// {// for (j=i-gap; j>=0 && v[j]>v[j+gap]; j-=gap) // {// temp = v[j];// v[j] = v[j+gap];// v[j+gap] = temp;// }// }// }//}
0 0
- 根据the c program 一书中源代码来测试shell排序法
- The C program language
- [c++] The BookStore Program
- C语言-数据结构-希尔排序(shell sort)-源代码
- The K Shell Program Guide(1)
- The Flow Chart of Running C Program
- The example program of C on point
- The practice program of C on point
- Shell Program
- shell program
- mysql根据排序结果来更新表
- C 语言Shell 排序
- shell排序-c语言
- shell排序C实现
- 【C++】map根据value排序
- 利用linux shell script来测试linux c程序------脚本自动化测试用例代替手动测试用例
- 利用linux shell script来测试linux c程序------脚本自动化测试用例代替手动测试用例
- 【算法】Shell排序--C++源代码(VS2015)
- 飞思卡尔(三)测速测正反转(K60 欧姆龙500线编码器DMA测速)
- n皇后问题
- Android大图片裁剪终极解决方案(上:原理分析)
- 软件测试的基因是什么?
- 常见内存泄露及解决方案
- 根据the c program 一书中源代码来测试shell排序法
- powshell第一步学习
- struts2在学习(十)--表单验证的两种方式
- debian(ubuntu) 系统 vsftpd 配置虚拟帐号
- Android大图片裁剪终极解决方案(中:从相册截图)
- 递归:遍历指定文件夹
- GitHub的使用
- 图像的锐化
- Android大图片裁剪终极解决方案(下:拍照截图)