博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
QuickSort快速排序
阅读量:2194 次
发布时间:2019-05-02

本文共 1319 字,大约阅读时间需要 4 分钟。

/* * ===================================================================================== * *       Filename:  QuickSort.c * *    Description:   * *        Version:  1.0 *        Created:  2014年06月11日 21时30分51秒 *       Revision:  none *       Compiler:  gcc * *         Author:  Wenxian Ni (Hello World~), niwenxianq@qq.com *   Organization:  AMS/ICT * * ===================================================================================== */#include
void swap(int *p, int *q){ int temp = *p; *p = *q; *q = temp;}int GetPos(int *p, int start, int end){ int posData = *(p+start); while(start
=posData) end--; if(end!=start) { *(p+start) = *(p+end); start++; while(start
<=posData) start++; if(start!=end) { *(p+end) = *(p+start); end--; } } } *(p+end) = posData; return end;}void QuickSort(int *p, int start, int end){ if(start >= end) return ; int pos = GetPos(p, start, end); QuickSort(p, start, pos-1); QuickSort(p, pos+1, end); return ;}int main(){ int a[10]; int n; int i; while(~scanf("%d",&n)) { for(i=0;i

转载于:https://my.oschina.net/vintnee/blog/640486

你可能感兴趣的文章
【LEETCODE】8-String to Integer (atoi)
查看>>
【LEETCODE】14-Longest Common Prefix
查看>>
【LEETCODE】38-Count and Say
查看>>
【LEETCODE】278-First Bad Version
查看>>
【LEETCODE】303-Range Sum Query - Immutable
查看>>
【LEETCODE】21-Merge Two Sorted Lists
查看>>
【LEETCODE】231-Power of Two
查看>>
【LEETCODE】172-Factorial Trailing Zeroes
查看>>
【LEETCODE】112-Path Sum
查看>>
【LEETCODE】9-Palindrome Number
查看>>
【极客学院】-python学习笔记-Python快速入门(面向对象-引入外部文件-Web2Py创建网站)
查看>>
【LEETCODE】190-Reverse Bits
查看>>
【LEETCODE】67-Add Binary
查看>>
【LEETCODE】7-Reverse Integer
查看>>
【LEETCODE】165-Compare Version Numbers
查看>>
【LEETCODE】299-Bulls and Cows
查看>>
【LEETCODE】223-Rectangle Area
查看>>
【LEETCODE】12-Integer to Roman
查看>>
【学习方法】如何分析源代码
查看>>
【LEETCODE】61- Rotate List [Python]
查看>>