数据结构实验之排序一:一趟快排( 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 冒泡排序和快速排序都是基于"交 ...
随机推荐
- 关于 Nginx的相关学习
转自:https://www.cnblogs.com/wcwnina/category/1193394.html Nginx能做什么 ——反向代理 ——负载均衡 ——HTTP服务器(动静分离) ——正 ...
- kubernetes第二章--集群搭建
- JavaScript前端图片压缩
实现思路 获取input的file 使用fileReader() 将图片转为base64 使用canvas读取base64 并降低分辨率 把canvas数据转成blob对象 把blob对象转file对 ...
- day33-python之多线程
1.多线程实例 # import threading # import time # # import threading import time class MyThread(threading.T ...
- org.apache.shiro.session.UnknownSessionException: There is no session with id [xxxx]的解决方案
org.apache.shiro.session.UnknownSessionException: There is no session with id [xxxx]的解决方案 背景描述 Sprin ...
- js 数组 去重 算法(转载)
以下内容可能有重复部分,项目有用上,但还没来得急整理和验证. 一:https://www.cnblogs.com/jiayuexuan/p/7527055.html 1.遍历数组法 它是最简单的数组去 ...
- php验证码案例
<?php header('Content-type:image/jpeg'); $img=imagecreatetruecolor(120,40); // 背景颜色 $bg_color=ima ...
- 安装folly库以及folly的ConcurrentHashMap的简单使用
我在写grpc的实例时, 需要使用一个多线程的hash map, C++标准库中没有多线程的hash map, facebook开源的folly中存在大量的基础类, 中间存在一个高性能的hash ma ...
- Android自动化测试探索(七)代码覆盖率统计
之前在 https://www.cnblogs.com/zhouxihi/p/11453738.html 这篇写了一种统计Android覆盖率的方式 但是对于一些比较复杂或者代码结构不够规范的项目,有 ...
- JSONObject对象
1.JSONObject介绍 JSONObject-lib包是一个beans,collections,maps,java arrays和xml和JSON互相转换的包. 方法: 的getString() ...