package javaapplication103;
import java.util.Scanner;
/**
*
* @author Sabit
*/
public class InsertonSort
{
public static void main(String[] args)
{
int size;
Scanner s = new Scanner(System.in);
System.out.println("Enter Arrya Size: ");
size = s.nextInt();
int array[] = new int[size];
System.out.println("Enter Araay Element: ");
for(int i=0;i<size;i++)
{
array[i]=s.nextInt();
}
System.out.println("Your Array:");
System.out.println("Befor Sort: ");
for(int i=0;i<size;i++)
{
System.out.print(array[i]+" ");
}
for(int i=0;i<size;i++)
{
int j = i-1;
int temp = array[i];
while(j>=0 && array[j]>temp)
{
array[j+1]=array[j];
j--;
}
array[j+1]=temp;
}
System.out.println("
After Sort:");
for(int i=0;i<size;i++)
{
System.out.print(array[i]+" ");
}
System.out.println("");
}
}
Output
Enter array size:
5
Enter array element:
3 4 76 2 7
Your array
Before sort:
3 4 76 2 7
After sort:
2 3 4 7 76
2 previous comments
Nat Rev Neurosci 8 4 312 319 <a href=https://bestcialis20mg.com/>cheapest cialis</a>
[url=https://newfasttadalafil.com/]Cialis[/url] Heard best with bell of stethoscope in left lateral decubitus position b. Oyeyzl Bqsscs <a href=https://newfasttadalafil.com/>cialis online</a> Jpczks https://newfasttadalafil.com/ - cialis Amoxicillin Cold Medication