Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Sort {
- private static final Object[] temp = null;
- /**
- * @param args
- */
- public static void main(String[] args) {
- System.out.println("Unsorted: ");
- int[] myArray = {12,34,52,56,8,32,0};
- for (int i = 0; i < 7; i++){
- System.out.println(myArray[i]);
- }
- int j;
- int key;
- int i;
- for(j = 1;j < 6; j++) {
- key = myArray[j];
- for(i=j-1;(i>=0)&&(myArray[i])<key;i--)
- {
- myArray[i+1] = myArray[i];
- }
- myArray[i+1]=key;
- }
- System.out.println("Sorted: ");
- for (int k = 0; k < 7; k++){
- System.out.println(myArray[k]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement