数据结构实验之排序一:一趟快排( SDUT 3398)
#include <stdio.h>
#include <string.h>
int a[110000];
void qusort(int l, int r, int a[])
{
int i = l, j = r;
int x = a[i];
if(i >= j) return ;
while(i < j)
{
while(i < j && a[j] >= x) j --;
a[i] = a[j];
while(i < j && a[i] <= x) i ++;
a[j] = a[i];
}
a[i] = x;
// qusort(l,i-1,a); // kuaipai
// qusort(i+1,r,a);
}
int main()
{
int n;
while(scanf("%d",&n) != EOF)
{
for(int i = 0; i < n; i ++)
{
scanf("%d",&a[i]);
}
qusort(0,n-1,a);
for(int i = 0; i < n; i ++)
{
if(i == 0) printf("%d",a[i]);
else printf(" %d",a[i]);
}
printf("\n");
}
return 0 ;
}
数据结构实验之排序一:一趟快排( SDUT 3398)的更多相关文章
- 数据结构实验之排序四:寻找大富翁(SDUT 3401)
#include <stdio.h> #include <stdlib.h> #include <string.h> void Swap(int a[], int ...
- 数据结构实验之排序七:选课名单 (SDUT 3404)
#include <stdio.h> #include <string.h> #include <stdlib.h> struct node { char data ...
- SDUT OJ 数据结构实验之排序一:一趟快排
数据结构实验之排序一:一趟快排 Time Limit: 1000 ms Memory Limit: 65536 KiB Submit Statistic Discuss Problem Descrip ...
- SDUT 3398 数据结构实验之排序一:一趟快排
数据结构实验之排序一:一趟快排 Time Limit: 1000MS Memory Limit: 65536KB Submit Statistic Problem Description 给定N个长整 ...
- SDUT-3398_数据结构实验之排序一:一趟快排
数据结构实验之排序一:一趟快排 Time Limit: 1000 ms Memory Limit: 65536 KiB Problem Description 给定N个长整型范围内的整数,要求输出以给 ...
- SDUT OJ 数据结构实验之排序二:交换排序
数据结构实验之排序二:交换排序 Time Limit: 1000 ms Memory Limit: 65536 KiB Submit Statistic Discuss Problem Descrip ...
- SDUT OJ 3403 数据结构实验之排序六:希尔排序
数据结构实验之排序六:希尔排序 Time Limit: 1000 ms Memory Limit: 65536 KiB Submit Statistic Discuss Problem Descrip ...
- SDUT 3402 数据结构实验之排序五:归并求逆序数
数据结构实验之排序五:归并求逆序数 Time Limit: 40MS Memory Limit: 65536KB Submit Statistic Problem Description 对于数列a1 ...
- SDUT 3399 数据结构实验之排序二:交换排序
数据结构实验之排序二:交换排序 Time Limit: 1000MS Memory Limit: 65536KB Submit Statistic Problem Description 冒泡排序和快 ...
- SDUT-3399_数据结构实验之排序二:交换排序
数据结构实验之排序二:交换排序 Time Limit: 1000 ms Memory Limit: 65536 KiB Problem Description 冒泡排序和快速排序都是基于"交 ...
随机推荐
- cocos版本说明
一直知道cocos是做游戏的,想学习一下,结果去官网一看就懵逼了.Cocos Creator,Cocos2d-x,cocos studio,Cocos2d-js,Cocos2d-x-lua,那一种才是 ...
- oracel 查询语句
1.以左边为显示表,从其他表查询关联的数据(多表查询) select a.*,b.name from da as a left join db as b on a.id = b.pid left jo ...
- 1.工厂模式(Factory Method)
注:图片来源于 https://www.cnblogs.com/-saligia-/p/10216752.html 工厂UML图解析: 工厂模式:client用户需要三步: 1.创建工厂: 2.生产产 ...
- windows下安装hexo和生成博客
首先在电脑上安装node和git,这个只要在相关官网的下载然后一步安装即可. 然后在你的电脑上新建一个文件夹,用来存放你的博客文件,比如创建hexo 进入该文件,右键打开git bash 安装hexo ...
- python day 8: re模块补充,导入模块,hashlib模块,字符串格式化,模块知识拾遗,requests模块初识
目录 python day 8 1. re模块补充 2. import模块导入 3. os模块 4. hashlib模块 5. 字符串格式:百分号法与format方法 6. 模块知识拾遗 7. req ...
- 73.移动端Web界面滚动性能优化 Passive event listeners
题,滚动时候不仅滚动了希望滚动的部分,整体的页面也跟随者上下滚动,整个页面非常卡顿. 这两个页面都用了touch事件 控制台打印如下警告: [Intervention] Unable to preve ...
- 【干货】小程序内嵌 H5 代码详解
自从微信小程序发布了 web-view 组件,使得之前的 H5 网站移植到小程序成为可能.现在,很多项目在迁移的过程中遇到了许多问题,本文通过实例代码,为你讲解迁移过程中的几个典型场景. 1.小程序和 ...
- 【cookie的使用】&【Session】
明确一点: cookie由服务器创建Cookie cookie=new Cookie("haha","xixi") 通过HtttpServletR ...
- MySQL Transaction--网络丢包导致长时间未提交事务
TCP三次握手(Three-Way Handshake) 建立一个TCP连接时,需要客户端和服务端总共发送3个包以确认连接的建立. TCP三次握手:第一次握手:Client将标志位SYN置为1,随机产 ...
- 计算机网络原理,TCP&UDP
UDP伪首部:计算校验和时会用到,然后实际传输过程中里包含的IP地址没有什么用. UDP校验和计算:求数值之和,如果溢出回卷,最后求出反码;UDP伪首部,UDP首部,应用层数据相加 tcp报文,最短2 ...