Import Java.util.Scanner;
/**
* @author Yangkuang
*
*/
public class Sort {
public static void Main (string[] args) {
int a[] = input ();
Insertsort (a);
Shellsort (a);
Selectsort (a);
Fastsort (a,0,a.length-1);
for (int k = 0; k < a.length; k++) {
System.out.print (A[k] + "");
}
}
static void Fastsort (Int[]a,int s,int t) {
int i=s;
int j=t;
if (s<t) {
int Last=a[s];
while (I!=J) {
while (J>i&&a[j]>=last) {
j--;
}
A[I]=A[J];
while (I<j&&a[i]<=last) {
i++;
}
A[j]=a[i];
}
A[i]=last;
Fastsort (a,s,i-1);
Fastsort (A, i+1, T);
}
}
Static int[] Selectsort (int a[]) {
for (int i = 0; i < a.length-1; i++) {
int min=i;
for (int j = i+1; J < A.length; J + +) {
if (A[j]<a[min]) {
Min=j;
}
}
if (min!=i) {
int temp=a[i];
A[i]=a[min];
A[min]=temp;
}
}
for (int i = 0; i < a.length; i++) {
System.out.print (A[i] + "");
}
return A;
}
Static int[] Insertsort (int a[]) {
for (int i = 1; i < a.length; i++) {
int temp = A[i];
int j = i-1;
while (J >= 0 && Temp < A[j]) {//The element moves backward one after the other, until it finds a position that is not smaller than the previous one (the correct position)
A[j + 1] = A[j];
j--;
}
A[j + 1] = temp;
}
for (int i = 0; i < a.length; i++) {
System.out.print (A[i] + "");
}
return A;
}
Static int[] Shellsort (int a[]) {
int gap = A.LENGTH/2;
while (Gap > 0) {
int gap=5;
for (int i = gap; i < a.length; i++) {
int temp = A[i];
int j = I-gap;
while (J >= 0 && Temp < a[j]) {
A[j + gap] = a[j];
J-= Gap;
}
A[j + gap] = temp;
}
Gap = GAP/2;
}
for (int i = 0; i < a.length; i++) {
System.out.print (A[i] + "");
}
return A;
}
Static int[] Input () {
Scanner Scanner = new Scanner (system.in);
int n = scanner.nextint ();
int a[] = new Int[n];
for (int i = 0; i < n; i++) {
A[i] = Scanner.nextint ();
}
return A;
}
}
Various sorting algorithms for the Java Foundation