Findryan

Untitled

Nov 19th, 2016
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. public class InsertionSort
  2. {
  3. public static void main(String args[])
  4. {
  5. int a[]={8,5,9,6,3,4,2,1,7,5};
  6.  
  7. for(int i=0;i<a.length;i++)
  8. {
  9. int min=a[i];
  10. int j=i;
  11. while((j>0)&&(min<a[j-1]))
  12. {
  13. a[j]=a[j-1];
  14. j--;
  15. }
  16. a[j]=min;
  17. }
  18.  
  19. for(int h=0;h<a.length;h++)
  20. {
  21. System.out.println(a[h]+",");
  22. }
  23. }
  24. }
Add Comment
Please, Sign In to add comment