A quick sort of sorting algorithm

Source: Internet
Author: User
Tags printf sort

Quick sort algorithm, with ascending order as an example

Operating system: Ubuntu

Compiling software: GCC

Results screenshot:

Source:

 #include <stdio.h> void quickSort (int *,int,int);  
      
int findposs (int *,int,int);  
int main () {int i;  
      
int arry[] = {8,9,0,-3,6,7,-11};  
      
QuickSort (arry,0,6);  
printf ("After sorted:\n");  
for (i=0;i<7;i++) printf ("%d", arry[i]);  
printf ("\ n");  
return 0;  
      
}//Quick sort function to implement void QuickSort (int *a,int low,int high) {int pos by recursion;  
  if (Low < high) {pos = Findposs (A,low,high);  
  QuickSort (A,LOW,POS-1);   
QuickSort (A,pos+1,high);  
} return; //The function returns the location of the value of the split point, A is the first address of the array to be sorted, and low just begins to represent the position of the first element within the sort range, gradually moving to the right, and high is just beginning to represent the last position within the sort range and moving the int fin  
Dposs (int *a,int low,int high) {int val = A[low];  
  While [low < High] {while (low=val) high--;  
      
  A[low] = A[high];  
  while (Low<=val) low++;       
A[high] = A[low];  
}//At this time Low=high a[low] = val;  
return to Low; }

Back to the column page: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/sjjg/

Author: csdn Blog Lan pavilion Wind and Rain

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.