随便写了个快速排序程序

来源:互联网 发布:html与javascript分离 编辑:程序博客网 时间:2024/04/29 03:08
#include <iostream>using namespace std;int InsertSort(int num[],int low,int high){int piov = 0;num[piov] = num[low];while(low < high){while(low < high && num[high] > num[piov])             high--;num[low] = num[high];while(low < high && num[low] < num[piov])             low++;num[high] = num[low];}num[low] = num[piov];return low;}void QSort(int n[],int l, int h){int piov ;if(l<h){piov = InsertSort(n,l,h);QSort(n,l,piov);QSort(n,piov+1,h);}}int main(){printf("输入");int thenum[11];int i;for(i = 1; i < 11; i++){cout << "输入第" << i << "个数" ;     cin>>thenum[i];}QSort(thenum, 1, 10);cout << "输出" << endl; for(i = 1; i < 11; i++)     cout << thenum[i]<< "   ";    return 1;}

0 0
原创粉丝点击