int 与 int *
#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 *的更多相关文章
- int main( int argc, char **argv)
1.参数 (有时参数是void) argc是程序运行时参数个数 argv是存储参数的数组,可以用char* argv[],也可以用char **argv. 例如编译一个hello.c的程序 1 #in ...
- C#中(int)、int.Parse()、int.TryParse()和Convert.ToInt32()的区别
转自:http://www.cnblogs.com/leolis/p/3968943.html 在编程过程中,数据转换是经常要用到的,C#中数据转换的方法很多,拿将目标对象转换为 整型(int)来讲, ...
- int(*f)(int)
int(*f)(int): 为指向函数的指针变量的定义方法,其中f为指向函数的指针变量,第一个int为函数返回值类型,第二个int为函数的形参类型.
- what is difference in (int)a,(int&)a,&a,int(&a) ?
This interview question come from a famous communication firm of china. : ) #include <iostream> ...
- C#中(int)、int.Parse()、int.TryParse()和Convert.ToInt32()的区别 <转>
作者:Statmoon 出处:http://leolis.cnblogs.com/ 在编程过程中,数据转换是经常要用到的,C#中数据转换的方法很多,拿将目标对象转换为整型(int)来讲,有四种方法 ...
- 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 ...
- (int)、int.Parse()、int.TryParse()和Convert.ToInt32()的区别
C#中(int).int.Parse().int.TryParse()和Convert.ToInt32()的区别 原文链接:http://www.cnblogs.com/leolis/p/3968 ...
- int main(int argc,char* argv[])详解
argc是命令行总的参数个数 argv[]是argc个参数,其中第0个参数是程序的全名,以后的参数命令行后面跟的用户输入的参数, 比如: int main(int argc, ...
- 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 ...
- int main(int argc, char * argv[]) 里的异常处理
#import <UIKit/UIKit.h> #import "AppDelegate.h" int main(int argc, char * argv[]) { ...
随机推荐
- Jquery对raido的一些操作方法
raido 单选组radio: $("input[type=radio][checked]").val(); 获 取一组radio被选中项的值 var item = $('i ...
- 500. Keyboard Row
Given a List of words, return the words that can be typed using letters of alphabet on only one row' ...
- CSS清除float浮动
一.浮动产生原因 - TOP 一般浮动是什么情况呢?一般是一个盒子里使用了CSS float浮动属性,导致父级对象盒子不能被撑开,这样CSS float浮动就产生了. 本来两个黑色对象盒子是在 ...
- AngularJS创建新指令directive参数说明
var myapp = angular.module('myapp', []); myapp.directive('worldname', function() { return { template ...
- Ubuntu搭建mysql,Navicat Premium连接
保存编辑结果与退出vim编辑器 https://jingyan.baidu.com/article/495ba8410ff14d38b30ede01.html 首先,我们需要使用apt安装mysql, ...
- UE4 Fade out Mesh
由于项目需要一个将场景慢慢淡入以及淡出的效果,所以就想了想实现思路.因为PBR光照模型是不支持透明物体的渲染的,所以UE4中的PBR材质在为Opaque时是无法改变透明度的,想来想去想不出解决方法,然 ...
- My SQL数据库的安装与配置
MySQL是一个关系型数据库管理系统.MySQL所使用的 SQL 语言是用于访问数据库的最常用标准化语言 MySQL 软件采用了双授权政策,分为社区版和商业版,由于其体积小.速度快.总体拥有成本低,尤 ...
- bzoj2876 [Noi2012]骑行川藏
Description 蛋蛋非常热衷于挑战自我,今年暑假他准备沿川藏线骑着自行车从成都前往拉萨.川藏线的沿途有着非常美丽的风景,但在这一路上也有着很多的艰难险阻,路况变化多端,而蛋蛋的体力十分有限,因 ...
- FrameBuffer系列 之 介绍
1. 来由 FrameBuffer是出现在2.2.xx内核当中的一种驱动程序接口.Linux工作在保护模式下,所以用户态进程是无法象 DOS 那样使用显卡 BIOS里提供的中断调用来实现直接写 ...
- AspNetCore-MVC实战系列(四)之结尾
AspNetCore - MVC实战系列目录 . 爱留图网站诞生 . git源码:https://github.com/shenniubuxing3/LovePicture.Web . AspNetC ...