HDU 1040 As Easy As A+B - Problem B
来源:互联网 发布:数据验证 excel 编辑:程序博客网 时间:2024/06/07 06:11
/**
排序模板题: 快排是比较快速的算法~
分治的思想, 把每个元素放到合适的位置
*/
#include <iostream>
#include <cstdio>
#include <queue>
#include <cstring>
#include <cmath>
#include <vector>
#include <iomanip>
#include <algorithm>
//#include "myAlgorithm.h"
#define MAXL 100005
#define INF 1e8
using namespace std;
int n;
int a[MAXL];
int partion(int low, int high){
int key = a[low];
while(low < high){
while(low < high && key <= a[high]){
high--;
}
swap(a[low], a[high]);
while(low < high && key >= a[low]){
low ++;
}
swap(a[low], a[high]);
}
return low;
}
void quickSort(int low, int high){
if(low < high){
int mid = partion(low, high);
quickSort(low, mid -1);
quickSort(mid + 1, high);
}
}
int main()
{
///freopen("in.txt","w",stdout);
int k;
cin>>k;
while(k--){
cin>>n;
for( int i = 0; i < n; i++){
cin>>a[i];
}
quickSort(0, n - 1);
for( int i = 0; i < n - 1; i++){
cout<<a[i]<<" ";
}cout<<a[n-1]<<endl;
}
return 0;
}
- HDU 1040 As Easy As A+B - Problem B
- HDU-1040 as easy as a+b
- hdu 1040 As Easy As A+B
- hdu 1040 As Easy As A+B
- hdu 1040 As Easy As A+B
- hdu 1040 As Easy As A+B
- hdu 1040 As Easy As A+B
- Hdu 1040 - As Easy As A+B
- HDU 1040 As Easy As A+B
- hdu-1040-As Easy As A+B
- As Easy As A+B hdu 1040
- HDU--1040 As Easy As A+B
- HDU 1040 As Easy As A+B
- HDU 1040 As Easy As A+B
- hdu 1040 As Easy As A+B
- HDU 1040 As Easy As A+B
- hdu 1040 As Easy As A+B
- hdu-1040 As Easy As A+B
- 检测文件是否存在
- Jar包说明
- ps命令查看内核线程
- Hadoop中的各种排序
- 引用外部.css或.js文件的路径问题
- HDU 1040 As Easy As A+B - Problem B
- Quartz 2D Programming Guide
- ibatis
- JavaScript
- java.lang.ClassNotFoundException: javax.servlet.jsp.jstl.core.LoopTag
- 基本排序算法代码
- linux system(string sCmd)命令用法
- JBPM
- 51CTO 在线阅读图书