#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;
    
}

int 与 int *的更多相关文章

  1. int main( int argc, char **argv)

    1.参数 (有时参数是void) argc是程序运行时参数个数 argv是存储参数的数组,可以用char* argv[],也可以用char **argv. 例如编译一个hello.c的程序 1 #in ...

  2. C#中(int)、int.Parse()、int.TryParse()和Convert.ToInt32()的区别

    转自:http://www.cnblogs.com/leolis/p/3968943.html 在编程过程中,数据转换是经常要用到的,C#中数据转换的方法很多,拿将目标对象转换为 整型(int)来讲, ...

  3. int(*f)(int)

    int(*f)(int): 为指向函数的指针变量的定义方法,其中f为指向函数的指针变量,第一个int为函数返回值类型,第二个int为函数的形参类型.

  4. what is difference in (int)a,(int&)a,&a,int(&a) ?

    This interview question come from a famous communication firm of china. : ) #include <iostream> ...

  5. C#中(int)、int.Parse()、int.TryParse()和Convert.ToInt32()的区别 <转>

    作者:Statmoon 出处:http://leolis.cnblogs.com/   在编程过程中,数据转换是经常要用到的,C#中数据转换的方法很多,拿将目标对象转换为整型(int)来讲,有四种方法 ...

  6. the difference between const int *, int * const, int const *

    Some people may be confused about the sequence of const and * on declaration in C++/C, me too. Now I ...

  7. (int)、int.Parse()、int.TryParse()和Convert.ToInt32()的区别

    C#中(int).int.Parse().int.TryParse()和Convert.ToInt32()的区别   原文链接:http://www.cnblogs.com/leolis/p/3968 ...

  8. int main(int argc,char* argv[])详解

    argc是命令行总的参数个数 argv[]是argc个参数,其中第0个参数是程序的全名,以后的参数命令行后面跟的用户输入的参数, 比如:       int   main(int   argc,   ...

  9. 35.按要求编写Java程序: (1)编写一个接口:InterfaceA,只含有一个方法int method(int n); (2)编写一个类:ClassA来实现接口InterfaceA,实现int method(int n)接口方 法时,要求计算1到n的和; (3)编写另一个类:ClassB来实现接口InterfaceA,实现int method(int n)接口 方法时,要求计算n的阶乘(n

      35.按要求编写Java程序: (1)编写一个接口:InterfaceA,只含有一个方法int method(int n): (2)编写一个类:ClassA来实现接口InterfaceA,实现in ...

  10. int main(int argc, char * argv[]) 里的异常处理

    #import <UIKit/UIKit.h> #import "AppDelegate.h" int main(int argc, char * argv[]) { ...

随机推荐

  1. EXCEL数据导入数据库实例(NPOI)

    Default.aspx 页面代码: 引用了:    <script src="../../js/jquery.easyui.min.js" type="text/ ...

  2. wow.js中各种特效对应的类名

    一.(页面在向下滚动的时候,有些元素会产生细小的动画效果.虽然动画比较小,但却能吸引你的注意.) 刚知道wow.js这个插件,之前访问别的网站下拉滚动条会出现各种效果感觉特别神奇,现在自己依葫芦画瓢也 ...

  3. javascript中类式继承和原型式继承的实现方法和区别

    在所有面向对象的编程中,继承是一个重要的话题.一般说来,在设计类的时候,我们希望能减少重复性的代码,并且尽量弱化对象间的耦合(让一个类继承另一个类可能会导致二者产生强耦合).关于“解耦”是程序设计中另 ...

  4. linux基础 作业篇

    1.自动部署反向代理 web nfs #!/usr/bin/python #-*- coding:utf-8 -*- #开发脚本自动部署及监控 #1.编写脚本自动部署反向代理.web.nfs: #!/ ...

  5. 一款Modbus设备调试工具Winform(包括SRC0001、海康威视、TTS以及各种类型LED的测试)

    1.SRC寄存器读写测试 2.采集数据终端模块(这里是康海时代)调试 3.RS485传感器设备调试 4.LED/TTS/海康威视等展示设备调试 5.Modbus等协议规约资料及4-20mA设备调试 以 ...

  6. 安装php提示 configure: error: Cannot find OpenSSL's libraries 解决方案

    一次在安装php7其中提示错误信息 configure: error: Cannot find OpenSSL's libraries 出现这种有2中情况,一种是没有安装 openssl,另一种是安装 ...

  7. PPT制作线条动画

    0.小叙闲言 今天在用PPT做动画的时候小有心得,百度了一下线条动画制作,有一个贴子里面的讨论,也给了我一些灵感,贴子地址:http://www.rapidbbs.cn/thread-24577-1- ...

  8. 由CODEVS笨小猴1053引发的一些思考

    #include<cstdio> #include<cstring> ]; ]; int check(int n) { ||n==) ; ;m*m<=n;++m) ) ; ...

  9. Java多线程中的单例模式

    一.在多线程环境下创建单例 方式一: package com.ietree.multithread.sync; public class Singletion { private static cla ...

  10. ubuntu下搭建nginx+mysql+php-fpm站点

    概述 Nginx ("engine x") 是一个高性能的 HTTP 和 反向代理 服务器,也是一个 IMAP/POP3/SMTP 代理服务器.  nginx的优势在于能以低内存高 ...