hdu 1040 As Easy As A+B(快排练习水题~)
2010-11-16 21:18
302 查看
自己第一次不看书写成快排~~欧也~~~
PE数次 = =。。。最后一个不要加空格 = =。。
PE数次 = =。。。最后一个不要加空格 = =。。
#include <stdio.h> #include <stdlib.h> #include <iostream> #include <memory.h> using namespace std; int n; int Partition(int a[],int p, int r) { int i = p-1; int x = a[r]; for(int j=p; j<r; j++) if( a[j] <= x ) { i++; swap(a[i],a[j]); } swap(a[i+1],a[r]); return i+1; } void QuickSort(int a[],int p,int r) { if( p < r ) { int q = Partition(a,p,r); QuickSort(a,q+1,r); QuickSort(a,p,q-1); } } int main(void) { int ncases; int a[1001]; scanf("%d",&ncases); while( ncases-- ) { scanf("%d",&n); for(int i=1; i<=n; i++) scanf("%d",&a[i]); QuickSort(a,1,n); for(int i=1; i<n; i++) printf("%d ",a[i]); printf("%d",a ); printf("/n"); } return 0; }
相关文章推荐
- hdu 1040 As Easy As A+B(堆排练习水题~)
- HDU 1040 As Easy As A+B(深感hdu水题太多。。。)
- 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
- As Easy As A+B hdu 1040
- [水题]hdoj1040 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
- hdu1040 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 ay A+B 20140805.cpp