快速排序
来源:互联网 发布:python pyqt5安装包 编辑:程序博客网 时间:2024/04/29 21:58
#include <stdio.h>/* *speed sort *author @ suilingxi *2014-1-15*/void speed_sort(int * array , int high ,int low){/* record the position of the array we want to sort */int i=low;int j=high;int temp=0;/* take the lowest number as the object we want to sort*/if(low<high){temp=*(array+low);/*find the position we want to insert*/while(i!=j){while((j>i)&&(*(array+j)>temp)){j--;}if(j>i){*(array+i)=*(array+j);i++;}while((j>i)&&(*(array+i)<temp)){i++;}if(i<j){*(array+j)=*(array+i);j--;}}*(array+i)=temp;speed_sort(array,i-1,low);speed_sort(array,high,i+1);}}int main(){int array[10];printf("please enter the array of number:\n");for(int i=0;i<10;i++){scanf("%d",&array[i]);}speed_sort(array,9,0);for(int i=0;i<10;i++){printf("%d ",array[i]);}return 0;}
0 0
- 快速排序
- 快速排序
- 快速排序
- 快速排序!
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- ClassLoader(包括一个工具类)
- opengl编程指南笔记(三)第二章 状态管理和绘制几何物体
- C++中的用来调试的宏
- android 典型问题:R.java文件不能自动生成的解决办法
- ActiveReports 报表控件的安装
- 快速排序
- MyEclipse无法找到BASE64Encoder
- ARM裸板开发配置流程一
- mysql 学习笔记
- Android Binder IPC分析
- (总结)Oracle 11g常用管理命令(用户、表空间、权限)
- Linux定时任务cron
- 总结一下ubuntu的chmod和chown命令
- PC版本游戏--cocos2d-x中文乱码解决办法(GBK到UTF-8编码)及其fatal error: iconv\iconv.h: No such file or directory问题