---
title: "排序算法－快速排序"
author: "fyc92"
date: "2013-10-28T15:41:35Z"
tags: []
categories: ["编程语言"]
slug: "untitled"
draft: false
lastmod: "2013-10-28T15:41:35Z"
id: 1965682
url: "https://fyc92.iteye.com/blog/1965682"
---

```java

public static void quick_sort(int[] a, int begin, int end){
		int start = 0;
		if (begin < end) {
			start = a[begin];
			int low = begin;
			int high = end;
			while(low < high){
				while(low < high && a[high] > start){
					high --;
				}
				a[low] = a[high];
				while(low < high && a[low] <= start){
					low ++;
				}
				a[high] = a[low];
			}
			a[low] = start;
			TIMES ++;
			quick_sort(a, begin, low - 1);
			quick_sort(a, low + 1, end);
		}
	}

public static int TIMES = 0;

public static void main(String[] args) {
		// TODO Auto-generated method stub    
		int a[] = {21,30,2,5,8,12,44,55,63,63,65};
		
		TIMES = 0;
        quick_sort(a, 0, a.length - 1);
		for (int i = 0; i < a.length; i++) {
			System.out.print(a[i]+",");
		}
		System.out.println("Quick Sort times : "+TIMES);
	}

```