Now there are fewer students in handwritten order, but in some subjects, the use of handwritten sort may make the topic more simple. Below I will upload some sort of template.
Quick Sort
Basic ideas I will not elaborate, recommend everyone to Baidu (do not understand the words can ask me), the following attached to this Konjac Konjac code.
#include <iostream>#include<cstdio>#include<cmath>#include<cstring>#include<algorithm>using namespacestd;inta[101],n;voidQuicksortintXinty) { inti=x,j=y; intk=A[x]; if(i>=j)return; while(i<j) { while(i<j&&a[j]>k) J--; if(i<j) {A[i]=A[j]; I++; } while(i<j&&a[i]<=k) I++; if(i<j) {A[j]=A[i]; J--; }} A[i]=K; Quicksort (X,i-1); Quicksort (i+1, y);}intMain () { for(intI=1; i<=Ten; i++) Cin>>A[i]; Quicksort (1,Ten); for(intI=1; i<=Ten; i++) cout<<a[i]<<" "; return 0;}
Xuan Shes
My blog: http://www.cnblogs.com/zbyrainbow/
This article is copyright to the author and the blog Park, Welcome to reprint, but without the consent of the author must retain this paragraph, and in the article page obvious location to the original link, otherwise reserves the right to pursue legal responsibility.
Sort Quick Sort (1~10)