Quickly sort Java code

Source: Internet
Author: User
Import Java.util.scanner;import Java.util.arraylist;public class Paixu2{public int[] alist;//quick sort public static void Main (String args[]) {Paixu2 he=new Paixu2 (); He.setup (); He.look (); He.go (0,9); He.look ();} public void Setup () {Scanner sc=new Scanner (system.in); alist=new int[10];for (int i=0;i<10;i++) {Alist[i]=sc.nextint ();}} public void Look () {System.out.println (""), for (int i=0;i<10;i++) {System.out.print (alist[i]);}} public void Change (int i,int j) {int tempp;tempp=alist[i];alist[i]=alist[j];alist[j]=tempp;} public void Go (int i,int j) {if (i>j) {return;} int S=i;int pointi=i;int Pointj=j;while (Pointj!=pointi) {while (pointj>pointi&&alist[pointj]>=alist[s ]) {pointj--;} while (Pointj>pointi&&alist[pointi]<=alist[s]) {pointi++;} if (pointj>pointi) {change (POINTI,POINTJ);}} Change (S,POINTJ); go (i,pointi-1); go (pointi+1,j);}}

Quickly sort Java code

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.