Advertisement
anudrul

Untitled

Jul 11th, 2013
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1.  
  2. public class Sort {
  3.  
  4. private static final Object[] temp = null;
  5.  
  6. /**
  7. * @param args
  8. */
  9. public static void main(String[] args) {
  10.  
  11. System.out.println("Unsorted: ");
  12. int[] myArray = {12,34,52,56,8,32,0};
  13. for (int i = 0; i < 7; i++){
  14. System.out.println(myArray[i]);
  15. }
  16.  
  17. int j;
  18. int key;
  19. int i;
  20. for(j = 1;j < 6; j++) {
  21.  
  22. key = myArray[j];
  23. for(i=j-1;(i>=0)&&(myArray[i])<key;i--)
  24. {
  25. myArray[i+1] = myArray[i];
  26.  
  27. }
  28. myArray[i+1]=key;
  29.  
  30.  
  31. }
  32. System.out.println("Sorted: ");
  33. for (int k = 0; k < 7; k++){
  34. System.out.println(myArray[k]);
  35. }
  36.  
  37. }
  38.  
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement