#include <iostream>
using namespace std;
int QKPass(int* , int , int);  //若声明为 int QKPass(int, int, int); 会显示错误

void QKSort(int a[], int low, int high){
    int pos;
    if(low < high){
        pos = QKPass(a, low, high);
        QKSort(a, low, pos - 1);
        QKSort(a, pos + 1, high);
    }
}

int QKPass(int *a, int low, int high){
    int x = a[low];
    while(low < high){
        while(low < high && a[high] >= x)
            high--;
        if(low < high){
            a[low] = a[high];
            low++;
        }
        while(low < high && a[low] <= x)
            low++;
        if(low < high){
            a[high] = a[low];
            high--;
        }
    }
    a[low] = x;
    return low;
}

int main(){
    int n, a[100];
    int i, j, t;
    
    cin >> n;
    for(i = 1; i <= n; i++)
        cin >> a[i];
    
    QKSort(a, 1, n);
    
    for(i = 1; i <= n; i++)
        cout << a[i] << " ";
        
    return 0;
    
}

最新文章

  1. Linux用户配置sudo权限
  2. UIAccessibilityElement
  3. 在网页中弹出qq临时会话
  4. css3 动画 执行一次
  5. POJ 1743 Musical Theme (后缀数组,求最长不重叠重复子串)(转)
  6. http://jingyan.baidu.com/article/e4511cf33479812b855eaf67.html
  7. Android Broadcaset 简介
  8. JBPM6教程
  9. SOAPtest报错:error occurred during initialization of vm解决方法
  10. jenkins-ant-jmeter
  11. APIView源码分析
  12. CSS| 學習心得
  13. 腾讯云启动数据库进程,提示No such host is known
  14. db2 事务日志
  15. spark RDD底层原理
  16. 安装Windows Installer服务
  17. CKFinder 自定义文件路径扩展ConfigurationPathBuilder
  18. OpenCV---对象测量
  19. css背景颜色渐变
  20. 洛谷 P1103 书本整理(动规)

热门文章

  1. CI Weekly #17 | flow.ci 支持 Java 构建以及 Docker/DevOps 实践分享
  2. ios 视频/图片压缩
  3. css伪类的组合用法
  4. JS作用域相关知识(#精)
  5. [ext4]磁盘布局 - group分析
  6. 通过bootloader向内核传输启动参数
  7. JS基础——入门必备
  8. Transform java future into completable future 【将 future 转成 completable future】
  9. Ajaxfileupload 总结(包括插件处理json格式bug的解决方案)
  10. Python简要学习笔记