归并排序
来源:互联网 发布:stm32 socket编程 编辑:程序博客网 时间:2024/06/06 01:18
#include<stdio.h>#include<stdlib.h>void GuiBing(int a[],int first,int mid,int last,int c[]){int i=first;int j=mid+1;int m=mid;int n=last;int k=0;while((i<=m)&&(j<=n)){if(a[i]<=a[j])c[k++]=a[i++];elsec[k++]=a[j++];}while(i<=m)c[k++]=a[i++];while(j<=n)c[k++]=a[j++];for(int l=0;l<k;l++)a[first+l]=c[l];}void Divide(int a[],int first,int last,int c[]){if(first<last){int mid=(first+last)/2;Divide(a,first,mid,c);Divide(a,mid+1,last,c);GuiBing(a,first,mid,last,c);}}int main(){int paixu[]={10,54,2,59,6,325,489,0,266,12,32,88};int temp[12];Divide(paixu,0,11,temp);for(int i=0;i<12;i++)printf("%d,",temp[i]);return 0;}
阅读全文
0 0
- 归并排序-归并排序
- 归并和归并排序
- 归并与归并排序
- 归并排序
- 归并排序
- 归并排序
- 归并排序
- 归并排序
- 归并排序
- 排序::归并
- 归并排序
- 归并排序
- 归并排序
- 归并排序
- 归并排序
- 归并排序
- 归并排序
- 归并排序
- MySQL日志设置及查看
- 浅析VO、DTO、DO、PO的概念、区别和用处
- ♥C++宏观技巧笔记
- Unity入门操作_音频_035
- 记一次被yield return坑的历程。
- 归并排序
- ubuntu下载android源码
- 关于Javascript的严格模式
- 实现推送接收并在指定页面中处理(涉及推送、service)
- note: how userspace relates to netdevice rings
- 杨辉三角
- Mongo插入文档操作
- C语言宏定义
- Eclipes导入MyEclipes项目,而无法给Tomcat识别的解决方法