字符串排序算法(冒泡、选择、插入、希尔、快速)
来源:互联网 发布:阿里云开放所有端口 编辑:程序博客网 时间:2024/05/01 23:22
int Partition(char *s, int low, int high){ char temp; temp = s[low]; while(low < high) { while(low<high && s[high]>=temp) --high; s[low] = s[high]; while(low<high && s[low]<=temp) ++low; s[high] = s[low]; } s[low] = temp; return low;}void QuickSortOfString(char *s, int low, int high){ int label; while(low < high) { label = Partition(s,low,high); QuickSortOfString(s,low,label-1); low = label + 1; }}
void swap(char *a, char *b){char temp;temp = *a;*a = *b;*b = temp;}void BubbleSort(char *s, int n){int i,j;for(i=0;i<n;i++){for(j=1;j<n-i;j++)if(s[j-1]>s[j])swap(&s[j-1],&s[j]);}}void SelectSort(char *s ,int n){int i,j,k;for(i=0;i<n-1;i++){k = i;for(j=i+1; j<n; j++)if(s[j]<s[k])k=j;if(k!=i){swap(&s[k],&s[i]);}}}void InsertSort(char *s, int n){int i,j;char temp;for(i=1; i<n; i++){j = i-1;temp = s[i];while(j>=0 && temp<s[j]){s[j+1] = s[j];j--;}s[j+1] = temp;}}void ShellSort(char *s, int n){int i,j,len;char temp;for(len=n/2;len>=1;len=len/2){for(i=len;i<n;i++){j=i-len;temp = s[i];while(j>=0 && temp<s[j]){s[j+len]=s[j];j=j-len;}s[j+len]=temp;}}}
1 0
- 字符串排序算法(冒泡、选择、插入、希尔、快速)
- 排序算法(选择、希尔、二分插入、冒泡、直接插入、快速排序)
- 排序算法-冒泡、插入、归并、希尔、快速、选择--代码总结
- 常用排序算法--冒泡,插入,选择,希尔,归并,快速
- 冒泡、选择、快速、插入、希尔、归并排序算法的小结
- 各种排序算法的稳定性(冒泡、选择、插入、快速、堆排序、希尔排序等)
- js实现排序算法(冒泡、选择、插入、二分插入、快速、希尔)
- js实现排序算法(冒泡、选择、插入、二分插入、快速、希尔)
- 小白学数据结构——四、排序算法Python(冒泡、选择、快速、插入、希尔、归并排序)
- java插入,希尔,快速,冒泡,选择排序
- 插入 | 希尔 | 冒泡 | 快速 | 选择 | 归并排序
- 排序算法汇总(选择排序 ,直接插入排序,冒泡排序,希尔排序,快速排序,堆排序)
- 排序算法汇总(选择排序 ,直接插入排序,冒泡排序,希尔排序,快速排序,堆排序)
- 常用的排序算法:插入排序,希尔排序,冒泡排序,选择排序,快速排序,归并排序
- 基本排序算法(选择、插入、冒泡)和希尔排序
- python(三)6种排序算法性能比较(冒泡、选择、插入、希尔、快速、归并)
- 10种排序算法总结(冒泡、选择、插入、希尔、归并、快速、堆、拓扑、锦标赛、基数)
- 十种排序算法总结(冒泡、插入、选择、希尔、归并、堆、快速,计数,桶,基数)
- debian 时间同步
- git服务配置
- JavaScript没有块级作用域
- Planing
- SSH 部分jar包的作用
- 字符串排序算法(冒泡、选择、插入、希尔、快速)
- 如何让你的电脑保持清爽
- RMAN Catalog vs Nocatalog(引用)
- Android中的lcd_density && 在应用源码中设置横竖屏和取消横竖屏
- 周星驰演艺经历
- 职场时间的管理艺术
- PDF创建及动态转换控件activePDF Server
- 耳目一新的汇小贷P2P网贷加盟连锁优势
- Glib库的安装和编译